Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi,
I am trying to get the exception message which is caught using cOnException.
I can see the stack trace in the cLog but I want to get the actual value and perform some action. As can be seen in the example below, how can I get the ERROR_MESSAGE of cOnException_1 in cSetBody_1? Below code is not even compiling.
Thanks,
In ESB you never ever need to use GlobalMap. Everything is stored within the Camel Exchange message.
for your need, you can use a cProcessor after cOnException, with some code like
Exception ex = exchange.getProperty(Exchange.EXCEPTION_CAUGHT,Exception.class);
if ( ex == null) { ex = pExchange.getProperty(Exchange.EXCEPTION_HANDLED,Exception.class); }
if ( ex != null) {
x_error_message = ex.getLocalizedMessage();
x_error_class = ex.getClass().getCanonicalName();
}
exchange.getIn().setBody(x_error_message+' - '+x_error_class);
Suggestions, please !!
In ESB you never ever need to use GlobalMap. Everything is stored within the Camel Exchange message.
for your need, you can use a cProcessor after cOnException, with some code like
Exception ex = exchange.getProperty(Exchange.EXCEPTION_CAUGHT,Exception.class);
if ( ex == null) { ex = pExchange.getProperty(Exchange.EXCEPTION_HANDLED,Exception.class); }
if ( ex != null) {
x_error_message = ex.getLocalizedMessage();
x_error_class = ex.getClass().getCanonicalName();
}
exchange.getIn().setBody(x_error_message+' - '+x_error_class);
Thanks Loko.