I want to catch all Exception from the routes.
I add this to OnExeption:
onException(Exception.class).process(new MyFunctionFailureHandler()).stop();
Then I create the MyFunctionureHandler class.
public class MyFunctionFailureHandler implements Processor { @Override public void process(Exchange exchange) throws Exception { Throwable caused; caused = exchange.getProperty(Exchange.EXCEPTION_CAUGHT, Throwable.class); exchange.getContext().createProducerTemplate().send("mock:myerror", exchange); } }
Unfortunately, it does not work, and I do not know why.
if there is an Exeption, the program should stop.
How can I find out why this code is not working?
thanks s.
source share