

What do you do when you've caught an exception? - paul_houle
http://gen5.info/q/2008/08/27/what-do-you-do-when-youve-caught-an-exception/

======
damienkatz
Set it free. If it crashes the program, it was yours all along.

~~~
acangiano
Damien jokes about this, but he wrote a great article about error handling:
<http://damienkatz.net/2006/04/error_code_vs_e.html>

~~~
paul_houle
I like that article!

------
russell
Paul makes some very good points. He advocates exception handling at the level
of the unit of work. The problem is what is the unit of work? As an example, I
was setting up a new Jboss installation and deployment of an application that
I am only getting familiar with. Catalina threw an exception about something
in the configuration, but didn't log anything. Finally, JBoss caught the
exception and just logged that the deployment had failed. The piece of code
that found the problem could have told me what was wrong.

Paul says that checked exception are a horrible mistake, because they cause
premature catching of exceptions, because ignoring the exception means that
the programmer has to change the signature of his method. I find swallowed
exceptions all over the place in reading code. And methods in the Sun
libraries exacerbate the problem by throwing multiple checked exceptions that
have to be swallowed. So to keep method signatures at a reasonable length,
more swallowed exceptions. Generic exceptions with error codes, like
SQLException, would make more sense.

Given the reality of Java Exception handling, I favor catching the exception
at the point where a reasonable error message can be composed and logged.,
Then throwing an unchecked exception to be caught at the level of the unit of
work.

Finally, Paul says always use finally to clean up your mess.

------
lbolognini
Is it any good fried?

