exception handling

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

exception handling

Demon Hunter
This post was updated on .
CONTENTS DELETED
The author has deleted this message.
Reply | Threaded
Open this post in threaded view
|

Re: exception handling

souciance
Yeah the order does matter, take a look at http://camel.apache.org/exception-clause.html , there is section in the beginning that shows an example of how camel looks and matches exceptions.

On Fri, Nov 4, 2016 at 7:46 AM, Demon Hunter [via Camel] <[hidden email]> wrote:
there are two exception I handle in my current camel route as below

<onException>
<exception>java.lang.Exception</exception>
 <exception>com.swift.ipla.types.InvalidSyntaxException</exception>
 
<setHeader headerName="HeaderMsg">
        <simple>${exception.message}</simple>
</setHeader>
<setHeader headerName="HeaderCause">
        <simple>${exception.cause}</simple>
</setHeader>
</onException>

In java, we have to catch general exception later and specific exception need to catch first. If we also need to do such that in apache camel. If so, my code will be like below? or it doesn't make any differences?

<onException>
 <exception>com.swift.ipla.types.InvalidSyntaxException</exception>
<exception>java.lang.Exception</exception>

<setHeader headerName="HeaderMsg">
        <simple>${exception.message}</simple>
</setHeader>
<setHeader headerName="HeaderCause">
        <simple>${exception.cause}</simple>
</setHeader>
</onException>



If you reply to this email, your message will be added to the discussion below:
http://camel.465427.n5.nabble.com/exception-handling-tp5789729.html
To start a new topic under Camel - Users, email [hidden email]
To unsubscribe from Camel - Users, click here.
NAML

Reply | Threaded
Open this post in threaded view
|

Re: exception handling

Quinn Stevenson
A little clarification - the order does matter, but not as much as it does in Java.

For the code snippets you posted, it doesn’t make any difference.  You’ve defined one onException block than handles multiple exceptions.  The order of the onException blocks themselves can effect which block is matches (in the case of two exceptions with the same “distance” from the caught exception).

The link souciance provided has an ok discussion of this, but Claus’s book (Camel In Action) has a much better discussion - an entire chapter on error handling.

> On Nov 4, 2016, at 3:35 AM, souciance <[hidden email]> wrote:
>
> Yeah the order does matter, take a look at
> http://camel.apache.org/exception-clause.html <http://camel.apache.org/exception-clause.html> , there is section in the
> beginning that shows an example of how camel looks and matches exceptions.
>
> On Fri, Nov 4, 2016 at 7:46 AM, Demon Hunter [via Camel] <
> [hidden email] <mailto:[hidden email]>> wrote:
>
>> there are two exception I handle in my current camel route as below
>>
>> <onException>
>> <exception>java.lang.Exception</exception>
>> <exception>com.swift.ipla.types.InvalidSyntaxException</exception>
>>
>> <setHeader headerName="HeaderMsg">
>>        <simple>${exception.message}</simple>
>> </setHeader>
>> <setHeader headerName="HeaderCause">
>>        <simple>${exception.cause}</simple>
>> </setHeader>
>> </onException>
>>
>> In java, we have to catch general exception later and specific exception
>> need to catch first. If we also need to do such that in apache camel. If
>> so, my code will be like below? or it doesn't make any differences?
>>
>> <onException>
>> <exception>com.swift.ipla.types.InvalidSyntaxException</exception>
>> <exception>java.lang.Exception</exception>
>>
>> <setHeader headerName="HeaderMsg">
>>        <simple>${exception.message}</simple>
>> </setHeader>
>> <setHeader headerName="HeaderCause">
>>        <simple>${exception.cause}</simple>
>> </setHeader>
>> </onException>
>>
>>
>> ------------------------------
>> If you reply to this email, your message will be added to the discussion
>> below:
>> http://camel.465427.n5.nabble.com/exception-handling-tp5789729.html <http://camel.465427.n5.nabble.com/exception-handling-tp5789729.html>
>> To start a new topic under Camel - Users, email
>> [hidden email] <mailto:[hidden email]>
>> To unsubscribe from Camel - Users, click here
>> < href="" target="_top" rel="nofollow" link="external">
>> .
>> NAML
>> <
http://camel.465427.n5.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml <http://camel.465427.n5.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>>
>>
>
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/exception-handling-tp5789729p5789744.html <http://camel.465427.n5.nabble.com/exception-handling-tp5789729p5789744.html>
> Sent from the Camel - Users mailing list archive at Nabble.com <http://nabble.com/>.