dev@glassfish.java.net

Re: handling unexpected exceptions

From: Lloyd Chambers <Lloyd.Chambers_at_Sun.COM>
Date: Thu, 14 May 2009 14:40:48 -0700

This is why long ago I wrote ExceptionUtil.getRootCause(); so many
situations involve a lot of wrapped-around crap, especially in a
remote JMX context. When I'm debugging, I almost always do:

debug( ExceptionUtil.getRootCause(e) );

On May 14, 2009, at 2:30 PM, Scott Oaks wrote:

>>> I was just going to bite my tongue, but I will argue that the
>>> finally clause is far, far better. Exception chaining is a
>>> frustrating thing; it makes root cause analysis very difficult. I
>>> definitely agree that in most cases it is a mistake...
>> What do you mean by "chaining?" By "chaining" I meant throwing a
>> new exception with the caught one as the cause of the new one.
>> Long chains of this type make for long stack traces, to be sure,
>> but they also tell a great deal about the root error and the
>> context in which it occurred.
>> Now, if by "chaining" you meant catching an exception and then
>> throwing a new one without bringing the original one along as the
>> cause of the new one, then that's what I referred to as "masking"
>> which is deadly.
>
> It's true; there are two kinds of things here, and I am conflating
> them. My bad.
>
> But still, even properly chained exceptions make root cause analysis
> harder, particularly in the appserver because it will eventually
> limit the length of the stack traces. And as you say, doing it wrong
> is quite deadly.

Lloyd Chambers
lloyd.chambers_at_sun.com
GlassFish Team