This week's book giveaway is in the OCAJP forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide 1Z0-808 and have Jeanne Boyarsky & Scott Selikoff on-line! See this thread for details.
A lot of java programmers just use following code for exception handling
I would like to hear your opinion about this overall exception catching. In my opinion it's dirty programming but I never found a good argument to proof this. Do you know examples where it's really important to catch Throwable (that means catching Error, RuntimeException, ...)???
In general, catching Throwable is not the right thing to do. A java.lang.Error usually indicates a very bad situation that means "all bets are off".
I like to let Error, and often RuntimeException, percolate up as far as possible in code. However, it may be worth catching either or both at the top of the call-stack, in main() of the application, or run() of the thread. This particularly if you want to do some logging or something.
Extra-special care should be taken of OutOfMemoryError, because this is a particularly bad Error. Squashing that is almost always going to be a bad idea.
If I see code that liberally sprinkles catch(Exception e) or catch(Throwable t), I tend to suspect that the programmer could not be bothered to think about error handling. In a quick-and-dirty utility, that can be excused; in industrial-strength code, it can't.
Betty Rubble? Well, I would go with Betty... but I'd be thinking of Wilma.