You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Vadim Vararu <va...@gmail.com> on 2014/11/03 16:53:27 UTC

Exception in the bean after onException

Hi,

I have a global error handler that passes the exchange to a processor.
I wonder why the exception attribute of the injected Exchange is null in
this case?

//GLOBAL ERROR MANAGEMENT
        onException(Throwable.class)
            .process(new GlobalLoggerProcessor());

I can find the message of the exception in a property of the exchange, but
the exception itself if NULL.

Thanks in advance, Vadim.

Re: Exception in the bean after onException

Posted by Vadim Vararu <va...@gmail.com>.
Solved, it was an issue on the Throwable object, not a Camel one. Thanks.

On Tue, Nov 4, 2014 at 9:27 AM, Vadim Vararu <va...@gmail.com> wrote:

> Yes, that works, but as i've observed, i get this way only the cause
> message, and not the whole stacktrace.
>
> On Mon, Nov 3, 2014 at 6:55 PM, Claus Ibsen <cl...@gmail.com> wrote:
>
>> Hi
>>
>> This is by design. As the on exception routes the exchange, so the
>> exchange needs to not have the exception in getException as that is
>> used to detect if a new exception is thrown during routing with
>> onException.
>>
>> So you can grab the caused exception from the exchange property, or if
>> you use a bean instead of .process, then just define an Exception type
>> in the method signature and Camel will provide the caused exception in
>> the parameter.
>>
>> On Mon, Nov 3, 2014 at 4:53 PM, Vadim Vararu <va...@gmail.com>
>> wrote:
>> > Hi,
>> >
>> > I have a global error handler that passes the exchange to a processor.
>> > I wonder why the exception attribute of the injected Exchange is null in
>> > this case?
>> >
>> > //GLOBAL ERROR MANAGEMENT
>> >         onException(Throwable.class)
>> >             .process(new GlobalLoggerProcessor());
>> >
>> > I can find the message of the exception in a property of the exchange,
>> but
>> > the exception itself if NULL.
>> >
>> > Thanks in advance, Vadim.
>>
>>
>>
>> --
>> Claus Ibsen
>> -----------------
>> Red Hat, Inc.
>> Email: cibsen@redhat.com
>> Twitter: davsclaus
>> Blog: http://davsclaus.com
>> Author of Camel in Action: http://www.manning.com/ibsen
>> hawtio: http://hawt.io/
>> fabric8: http://fabric8.io/
>>
>
>

Re: Exception in the bean after onException

Posted by Vadim Vararu <va...@gmail.com>.
Yes, that works, but as i've observed, i get this way only the cause
message, and not the whole stacktrace.

On Mon, Nov 3, 2014 at 6:55 PM, Claus Ibsen <cl...@gmail.com> wrote:

> Hi
>
> This is by design. As the on exception routes the exchange, so the
> exchange needs to not have the exception in getException as that is
> used to detect if a new exception is thrown during routing with
> onException.
>
> So you can grab the caused exception from the exchange property, or if
> you use a bean instead of .process, then just define an Exception type
> in the method signature and Camel will provide the caused exception in
> the parameter.
>
> On Mon, Nov 3, 2014 at 4:53 PM, Vadim Vararu <va...@gmail.com>
> wrote:
> > Hi,
> >
> > I have a global error handler that passes the exchange to a processor.
> > I wonder why the exception attribute of the injected Exchange is null in
> > this case?
> >
> > //GLOBAL ERROR MANAGEMENT
> >         onException(Throwable.class)
> >             .process(new GlobalLoggerProcessor());
> >
> > I can find the message of the exception in a property of the exchange,
> but
> > the exception itself if NULL.
> >
> > Thanks in advance, Vadim.
>
>
>
> --
> Claus Ibsen
> -----------------
> Red Hat, Inc.
> Email: cibsen@redhat.com
> Twitter: davsclaus
> Blog: http://davsclaus.com
> Author of Camel in Action: http://www.manning.com/ibsen
> hawtio: http://hawt.io/
> fabric8: http://fabric8.io/
>

Re: Exception in the bean after onException

Posted by Claus Ibsen <cl...@gmail.com>.
Hi

This is by design. As the on exception routes the exchange, so the
exchange needs to not have the exception in getException as that is
used to detect if a new exception is thrown during routing with
onException.

So you can grab the caused exception from the exchange property, or if
you use a bean instead of .process, then just define an Exception type
in the method signature and Camel will provide the caused exception in
the parameter.

On Mon, Nov 3, 2014 at 4:53 PM, Vadim Vararu <va...@gmail.com> wrote:
> Hi,
>
> I have a global error handler that passes the exchange to a processor.
> I wonder why the exception attribute of the injected Exchange is null in
> this case?
>
> //GLOBAL ERROR MANAGEMENT
>         onException(Throwable.class)
>             .process(new GlobalLoggerProcessor());
>
> I can find the message of the exception in a property of the exchange, but
> the exception itself if NULL.
>
> Thanks in advance, Vadim.



-- 
Claus Ibsen
-----------------
Red Hat, Inc.
Email: cibsen@redhat.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen
hawtio: http://hawt.io/
fabric8: http://fabric8.io/