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?

有帮助吗?

解决方案

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

<handled>
    <constant>true</constant>
</handled>
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top