2011/3/24 Cédric Beust ♔ <[email protected]> > > > On Thu, Mar 24, 2011 at 10:49 AM, Kevin Wright > <[email protected]>wrote: > >> >>>> >>>> Again, name a SINGLE checked exception that everyone agrees should be >>>> checked. >>>> >>> >>> FileNotFound. >>> >>> >> a) I neither want nor need a stacktrace (+ associated construction cost) >> in such a scenario >> > > You are very unlikely to see one, unless you use a runtime exception, which > you will most likely forget to handle. >
Of course not, hence my desire to not waste time and resources building an in-memory representation of the thing! b) There may be a long chain of callers between where the exception is >> thrown and where it might reasonably be handled, if some of those >> intervening methods are generic and could also be used for other non-file >> operations then I certainly don't want to pollute their signatures. >> > > There are patterns to avoid that. Exceptions that cross layer boundaries > should be wrapped, although FileNotFoundException is probably an... er... > exception to this rule. Either way, you want to handle that one and do > something about it, and it's important enough that the compiler should make > sure you don't forget to do it. > Very often, I'll write code that just can't do *anything* if a particular file is not found. In that case the thing should propagate to the top-level exception handler where it can simply be reported as-is, awaiting user input. -- > Cédric > > > -- Kevin Wright gtalk / msn : [email protected] <[email protected]>mail: [email protected] vibe / skype: kev.lee.wright quora: http://www.quora.com/Kevin-Wright twitter: @thecoda "My point today is that, if we wish to count lines of code, we should not regard them as "lines produced" but as "lines spent": the current conventional wisdom is so foolish as to book that count on the wrong side of the ledger" ~ Dijkstra -- You received this message because you are subscribed to the Google Groups "The Java Posse" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/javaposse?hl=en.
