This content has been marked as final. Show 4 replies
It depends a good deal on what you're doing. The different exception types signify different things that can go wrong with an operation. In some cases, your program may be able to recover gracefully from one type of exception (e.g. if the file is not found, use a default file), but not another (how does one gracefully recover from an OutOfMemoryError).
There are places where I've actually found the naughty
and even its pure evil cousin
to be useful. This usually happens in places where the user is expecting me to tell them if something went wrong after they click a button or something--it's more helpful to pop up a message box telling them that an unspecified error occurred (i.e. my code's screwed up) than to let the exception go, in which case it will print gobbledygook out to the screen (if a console window is up) and the gui will do nothing.
Normally even in this situation you should catch as many specific exception types as you can and then if you need to, pull a catch(Throwable) and alert the user or at least log the exception so that you can fix it later.