camel-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Daniel Pocock <>
Subject onException documentation
Date Fri, 12 Dec 2014 09:26:24 GMT

In the wiki, it very briefly mentions that onException supports nested

"Camel will start from the bottom (nested caused by) and recursive up in
the exception hierarchy to find the first matching |onException| clause"

In the code, CatchProcessor.catches() uses
           for (final Throwable e :
ObjectHelper.createExceptionIterable(exception)) {

The ObjectHelper javadoc says
    Creates an Iterable to walk the exception from the bottom up
    (the last caused by going upwards to the root exception).

Looking at the createExceptionIterable code, it appears that the root
exception is the first returned by the iterator.  The stuff in the
comment in parentheses is not clear: when I see the word "last", it
gives me the impression that it is talking about the last in time order
and that is the opposite of what the method does.  In this context, I
think it is intended that the word "last" means the bottom or last
exception in a printed stack trace.

This feature is quite useful and it is something that could be clearer
in the wiki, rather than being buried half way down, it would be nice to
make the point at the top that onException can recognize any exception
in a chain and not just the exception wrapping all the others.  E.g. the
SMPP component often wraps the NegativeResponseException from jSMPP in
SmppException but it is much more useful to use onException with a
NegativeResponseException to extract the SMPP error code.

I don't mind updating this documentation myself but I thought it would
be useful to confirm that this is how people intend it to be used.



  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message