deltaspike-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jason Porter <lightguard...@gmail.com>
Subject Re: Exception handling loss of the root cause.
Date Wed, 22 Feb 2017 16:25:02 GMT
You have to unwrap exceptions, it's like a stack, not a queue. In your
examples, your "previous cause" is actually your root cause. You're
thinking about it backwards. The easiest way to view this in an application
is to get a JPA/JDBC error and look at exception chain. You'll notice the
original exception from the database is at the very core and all the other
exceptions wrap it.

On Wed, Feb 22, 2017 at 3:04 AM, Vincent Biertho <vincent.biertho@onem.be>
wrote:

>
>
> Hi,
> There is a strange behaviour in the exception handling...
>
> Looking the org.apache.deltaspike.core.api.exception.control.event.
> ExceptionStackEvent.init() line 96
> current = exceptionStackItems.removeFirst().getThrowable();
> This removes the first original exception when handling exception events...
>
> Then when throwing this anywhere:
> throw new RuntimeException("RootCause", new RuntimeException("previous
> cause"));
>
> or in a normal catch block
> } catch (final Exception ex) {
>             throw new CustomException("previous cause",ex);
> }
>
> A method with a param @Handles final ExceptionEvent<Exception> evt
> will give the "previous cause" exception... not the RootCause when evt
> .getException(); is called
>
> This behaviour and loss of information is really anoying ...
> Is this a wanted or a bug ?
>
>
> Vincent Biertho
> Java Team ONEm/RVA
> vincent.biertho@onem.be
> 02/515.44.01Disclaimer
>



-- 
Jason Porter
http://en.gravatar.com/lightguardjp

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message