You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Frank <fd...@gmail.com> on 2012/02/28 05:39:21 UTC

How to rethrow a caught exception in CAMEL

Hi, 

I am able to catch Exception sucessfully using
onException()/doTry...doCatch(). But, I don't know how rethorw the same
exception to the caller. Can any one please help me?

Thanks,
Frank

--
View this message in context: http://camel.465427.n5.nabble.com/How-to-rethrow-a-caught-exception-in-CAMEL-tp5520830p5520830.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: How to rethrow a caught exception in CAMEL

Posted by Claus Ibsen <cl...@gmail.com>.
On Tue, Feb 28, 2012 at 5:39 AM, Frank <fd...@gmail.com> wrote:
> Hi,
>
> I am able to catch Exception sucessfully using
> onException()/doTry...doCatch(). But, I don't know how rethorw the same
> exception to the caller. Can any one please help me?
>

The caused exception is stored as a property on the Exchange with the
key: Exchange.EXCEPTION_CAUGHT

When using a bean Camel can bind the caused exception to a parameter
of the type Exception, so you can do as below:
public class MyExceptionThrower
public static void throwUp(Exception e) throws Exception {
   throw e;
}
}

And then route the message to this bean.



> Thanks,
> Frank
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/How-to-rethrow-a-caught-exception-in-CAMEL-tp5520830p5520830.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-----------------
FuseSource
Email: cibsen@fusesource.com
Web: http://fusesource.com
Twitter: davsclaus, fusenews
Blog: http://davsclaus.blogspot.com/
Author of Camel in Action: http://www.manning.com/ibsen/