2

So I have the following route (Camel 2.20.0)
I was working on a global <onException> block for a new route. For some reason it wasn't firing, so I moved the items to a doTry/doCatch within one specific route just to play with the error handeling.

<camelContext xmlns="http://camel.apache.org/schema/spring" id="jobfeedCamelContext">
    <route id="testError">
        <from uri="timer://runOnce?repeatCount=1&amp;delay=5000" />
        <doTry>
            <throwException exceptionType="java.lang.Throwable"/>
            <to uri="errorBean"/> <!-- bean does nothing but explicitly throws java.lang.Throwable -->
            <doCatch>
                <exception>java.lang.Throwable</exception>
                <log message="### exception" />
            </doCatch>
        </doTry>
        <log message="### out of try" />
    </route>
</camelContext>

For output I get the stack trace from the beans java.Lang.Throwable (but no stacktrace is generated for the<throwException exceptionType="java.lang.Throwable"/>. I do not get my "### exception" log entry in any scenario, but I do get the "### out of try" log entry.

Have used this functionality in other routes on older version of camel, so I can't really see where I am going wrong. Anyone have any ideas? I've turned on route tracing and there is nothing helpful.

Brian Sallee
  • 81
  • 1
  • 4
  • 2
    I am pretty sure this is because throwing `Throwable` . Camel is able handle everything extending `Exception`, (This is why you can see `throws Exception` in every `Processor#proces()` method signature). `Throwable` is top level exception, so does not extends `Exception`, so cannot be handled. It should work if you change it to ``. Please [Never throw Throwable in Java](https://stackoverflow.com/questions/12564428/is-throws-throwable-good-practice) – Bedla May 15 '18 at 21:06
  • No difference when I change to `` but changeling the exception type in the bean did work. So now just to figure out why `` doesn't work (my route doesn't need it - am just curious at this point. – Brian Sallee May 16 '18 at 18:23

1 Answers1

0

<throwException exceptionType="java.lang.Throwable" message="some text"/>