UncheckedIOException and suppressed exception
david.holmes at oracle.com
Mon Feb 4 17:56:55 PST 2013
On 5/02/2013 10:16 AM, Zhong Yu wrote:
> Suppose we have an UncheckedIOException e1, which wraps an IOException
> e2. Then another exception e3 occurs that we want suppress. Should we
> do e1.addSuppressed(e3), or e2.addSuppressed(e3)? That's pretty
I don't see any confusion except for your numbering. You have one
exception that is inflight, e1, and then e3 occurs. If you want to
continue throwing e1 then e1 is suppressing e3.
> If UncheckedIOException is not a *real* exception, maybe we should
> make it a "control" exception. It should have no stacktrace; it should
> have no cause (the wrapped exception is not a cause); it should not
> contain suppressed exceptions.
Any wrapping exception should have the original exception as its cause.
Why should this wrapper be any different? Throwable even defines it so:
" Throwing a "wrapped exception" (i.e., an exception containing a cause)
Suppression is about control over which exception is propagating - so
again why should this be a special case?
> Maybe it can override addSuppressed() to forward suppressed exceptions
> to the wrapped exception. (Though addSuppressed() is `final`, there's
> no problem to leave a backdoor for another JDK class)
I think your exception processing model is slightly confused here.
> Zhong Yu
More information about the lambda-dev