That's gr8 :)
I tried to apply ur approach but it doesn't work into my case .
As my case has multiple processors and after one of those processors into
the middle I need to log the exchange's exception using DSL .
Applying this approach couldn't allow me to go and continue the rest of
chained processes 

In my case I have a route like : 


this.onException(classOf[IOException]).process(doSmth).log(LoggingLevel.INFO,
"new",     "${exception.stacktrace}")


My processor :

    Exception exception = exchange.getProperty(Exchange.EXCEPTION_CAUGHT,
classOf[Exception])
     CustomException customException=CustomException(exception)

When the onException goes to the DSL logging part , it will print the stack
trace as a IOException 
Instead I need to be CustomException

I have managed to do some work around by doing the following @ processor :

exchange.getOut.setHeader("ex",customException)

then @Route :

this.onException(classOf[IOException]).process(doSmth).log(LoggingLevel.INFO,
"new", ${in.header.ex} ")


It prints into my log the following and that what I exactly need from the
beginning :
CustomException: java.lang.IOException

What's wired is when I use ${exception.stacktrace} it prints the whole stack
trace as needed.
When I googled it , I found out  that expression fetches 

exchange.getProperty(Exchange.EXCEPTION_CAUGHT) and prints its stack trace .

However when I debug what returns from 
exchange.getProperty(Exchange.EXCEPTION_CAUGHT)
doesn't have stack trace 

So do u know from where does it fetch the stack trace when I type
${exception.stacktrace}!








    








--
View this message in context: 
http://camel.465427.n5.nabble.com/Fetch-Custom-Exception-from-the-exchange-tp4615183p4616849.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Reply via email to