camel-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Claus Ibsen (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (CAMEL-4022) Issue using errorBuilderRef with the xml dsl
Date Sun, 05 Jun 2011 12:47:47 GMT

    [ https://issues.apache.org/jira/browse/CAMEL-4022?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13044520#comment-13044520
] 

Claus Ibsen commented on CAMEL-4022:
------------------------------------

The current logic for onException is as follows:

1. onException will shadow any errorHandler
2. any errorHandler does not take part if onException is processing an exception (this is
the intend, but Hadrian created an unit test where the DLC interfered)


The logic in onException is roughly a "magic" try .. catch
{code}
try

   // while loop routing the exchange
 
} catch (OnException e) {
   try {
      // onException route logic goes here, if there is any
   } catch (Throwable t) {
      // ops an exception occurred in onException, we will store it on the exchange
      // TOOD: this is where we may want the onExceptionErrorHandler (to log the exception
or something)
      exchange.setException(t);
   }
   
   if (!continued) {
      // mark exchange to stop routing (this is the default behavior)
   }
   if (!handled) {
      // if onException is configured to NOT handle, then rethrown exception (this is the
default behavior)
      throw exchange.getException();
   }
}
{code}

So if an exception is thrown during onException processing, then that exception is caught.
But we may want to introduce that OnExceptionErrorHandler (FatalErrorHandler as named by Hadrian)
to log the exception (I think that's already done). But having an OnExceptionErrorHandler,
we could let end user configure what to do. But again this may just become more complicated.



> Issue using errorBuilderRef with the xml dsl
> --------------------------------------------
>
>                 Key: CAMEL-4022
>                 URL: https://issues.apache.org/jira/browse/CAMEL-4022
>             Project: Camel
>          Issue Type: Bug
>    Affects Versions: 2.7.1
>            Reporter: Hadrian Zbarcea
>            Assignee: Hadrian Zbarcea
>            Priority: Critical
>
> While fixing issues around the errorHandler I noticed that <onException> definitions
defined in the camel context are ignored if a route specifies its own errorHandlerRef. The
reason is that we set the onException definition on the default error handler. I have a fix
for that, but I discovered a different issue (I think) for which I would like to discuss the
solution.
> When we have an onException definition that looks kinda like this:
> {code}
> <onException>
>   <exception> java.lang.IllegalArgumentException</exception>
>   <to uri="mock:illegalArgumentException"/>
> </onException>
> {code}
> ... something happens, the IAE exception is caught, we do something, but in that process
another exception is thrown. Currently, that would be caught by the default error handler,
which may not be what we want.
> What error handler (if any) should handle exceptions thrown while in onException?
> The onException mechanism is somewhat similar to a try/catch. I don't think the exceptions
thrown while handling onException should be handled by the same error handler configured for
the route, or even the context scoped one. The processing should be very simple, predictable
and immutable. Since the default "CamelDefaultErrorHandlerBuilder" can be replaced, it is
not imho a solution and we need one global one that does as little as possible (the problem
would be agreeing what that is: no redeliveries, logging or not, etc).
> Thoughts?

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

Mime
View raw message