Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik GA: Multivariate Time Series in Qlik Predict: Get Details
cancel
Showing results for 
Search instead for 
Did you mean: 
Mahboob
Contributor
Contributor

How to get the error message inside Route (cOnException)

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.

 

 

0683p000009M2cP.jpg

 

 

Thanks,

Labels (2)
1 Solution

Accepted Solutions
Loko
Creator II
Creator II

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);

View solution in original post

3 Replies
Mahboob
Contributor
Contributor
Author

Suggestions, please  !!

Loko
Creator II
Creator II

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);

Mahboob
Contributor
Contributor
Author

Thanks Loko.