I am trying to handle an exception within apache camel in onException. Can someone guide me if it is possible?
I have written another onException which will handle all Exceptions, but the flow is not transferred to that exception block
onException(SchemaValidationException.class)
.to("xslt:stylesheet/example/TransformErrorBlock.xsl?saxon=true")
.log("Validation error in received message, response sent: ${body}")
.handled(true);
My expectation is if there is an exception in this block, it should be caught in another onException block
You cannot do this as its by design that Camel only allows onException block to handle exceptions, otherwise you can end up with endless looping when onException A is handled by onException which causes a new exception that may then be handled by onException A again, and so endless looping in circles.