You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Echo <ah...@gmail.com> on 2011/07/20 10:53:54 UTC

Re: Routing with RouteBuilder and onException, missing the Exception instance

Hello , 
I have the same case u were into .

I have declared my CustomException class. 
When the onException() catches it , it goes to the processor I defined : 

onException(classOf[CustomException]).process(doSmth) 

So far so good . 
The issue that I need into the processor to check if the exception is of
type "CustomException" or not 

when I write : 

 def process(exchange: Exchange) = { 
    val exception: CustomException=
exchange.getProperty(Exchange.EXCEPTION_CAUGHT, classOf[CustomException]) 

I got null 

But when I write : 

 def process(exchange: Exchange) = { 
    val exception: Exception =
exchange.getProperty(Exchange.EXCEPTION_CAUGHT, classOf[Exception]) 

I got my exception object 

How could I check which type of exception is thrown into the processor !

The type of exception under CamelExceptionCaught property is
ava.lang.reflect.UndeclaredThrowableException

--
View this message in context: http://camel.465427.n5.nabble.com/Routing-with-RouteBuilder-and-onException-missing-the-Exception-instance-tp476479p4615187.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Routing with RouteBuilder and onException, missing the Exception instance

Posted by Echo <ah...@gmail.com>.
I was trying to wrap the caught exception that comes into the exchage and
wrap it into another custom exception .

After this wrapping I need to set this exception into a custom exchange .
I have discoverd later from @Claus Ibsen-2 on the camel forum that Camel
won't cont. routing when I use 

    exchange.setException(ex)

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 


--
View this message in context: http://camel.465427.n5.nabble.com/Routing-with-RouteBuilder-and-onException-missing-the-Exception-instance-tp476479p4619696.html
Sent from the Camel - Users mailing list archive at Nabble.com.