You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Alexander Lomov <al...@gmail.com> on 2013/12/17 13:45:33 UTC

Trying to figure out how errorHandler, onException and throwException work.

Hi Camel Riders,
I've stumbled over errorHandler and onException features and still couldn't
figure out what are theirs limitations. I'm concerned with having three
routes, each in a separate Blueprint Camel context, let's call them
'facade', 'mediator' and 'support'.
Facade is invoked via CXF-RS, passes exchanges to mediator which leverages
from support to enrich messages and may produce some call-outs to downstream
systems. Then the exchange should be returned to the caller via the facade. 
We have a bunch of strictly defined exceptions that can be thrown  by the
mediator to the facade and facade has to translate those exception to some
response error structures for the caller.
So let's assume the support throws some support-specific exception on some
circumstances, thus the mediator has to handle this exception and adapt is
as a strictly defined exception and throw it to the facade.
The straightforward approach for us was to handle the exception from support
route and throw the strictly defined one:
onException(SomeSupportException.class).handled(true).throwException(new
StrictlyDefinedException()).end(). It seems Camel doesn't like this
construction because of blaming 'Exception occurred while trying to handle
previously thrown exception on exchangeId'.
Setting errorHandler to noErrorHandler seems to disable onException as well.
Sorry for the long preamble and thanks for staying with us :)
Is there any proper approach to:
Bubble an exception from the 'support' route, handle it in the 'mediation'
route which is parent to the 'support', bubble *another exception* from the
'mediation' route to the 'facade' route and finally handle the exception in
the 'facade' route?
Thanks in advance.
P.S. While looking to the NoErrorHandlerBuilder code  I've seen that it
handles onException policies somehow.
Am I doing something wrong?



--
View this message in context: http://camel.465427.n5.nabble.com/Trying-to-figure-out-how-errorHandler-onException-and-throwException-work-tp5744947.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Trying to figure out how errorHandler, onException and throwException work.

Posted by Alexander Lomov <al...@gmail.com>.
Figured out.
.doTry()
.doCatch()
    .throwException()
is able to pierce through error handler. Not that elegant as onException,
but it solves the problem.
So thanks to Camel developers for providing multiple tools to handle the
problem.



--
View this message in context: http://camel.465427.n5.nabble.com/Trying-to-figure-out-how-errorHandler-onException-and-throwException-work-tp5744947p5744956.html
Sent from the Camel - Users mailing list archive at Nabble.com.