You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by "Vanshul.Chawla" <Va...@target.com> on 2015/09/22 10:00:12 UTC

Changing exception message in Camel

Hello,

I have a route which has an onException block.

<setHeader headerName="DASResponse">
       <simple>${exception.message}</simple>
</setHeader>
<log message="Exception before is ${exception}"/>
<setProperty propertyName="Exchange.EXCEPTION_CAUGHT">
       <constant>3000: Error code other than 50 sent by DAS</constant>
</setProperty>
<log message="Exception 1 is ${exception}"/>
<setHeader headerName="Exchange.EXCEPTION_CAUGHT">
<simple>3000: Error code other than 50 sent by DAS</simple>
</setHeader>
<log message="Exception now is ${exception}"/>


So ${exception.message} gives a proper DASResponse header. Then I need to create a custom exception to be handled by exception handler java classes. When I do setProperty, it makes exception as null.

Is there a way we can set the value to a custom value?


Vanshul