Question

I am trying to provide a custom message upon validation failure as oppose to the sending the stack trace to the user. It seems I am not understanding how to do this. My route is as follows:

        <route>
            <from uri="restlet:/foo"/>
            <onException>
                <exception>org.apache.camel.ValidationException</exception>
                <transform>
                    <simple>Validate your stuff</simple>
                </transform>        
                <stop/> 
          </onException>
            <validate><constant>false</constant></validate>

            <to uri="mock:result"/>
        </route>    

I tried to place the onException before or after the validation. Neither works. What I want to return to the user is 'Validate your stuff' as opposed to the complete stack trace.

Any clue?

Was it helpful?

Solution

You could mark the exception as handled before your <transform> with:

<handled>
    <constant>true</constant>
</handled>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top