[
https://issues.apache.org/jira/browse/CAMEL-7071?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13850038#comment-13850038
]
Willem Jiang edited comment on CAMEL-7071 at 12/17/13 3:04 AM:
---------------------------------------------------------------
Collections.reverse(tree) is used to make sure we can get the first cause of
exception in the catch() DSL and ErrorHandler.
Here are the Javadoc of the Exchange.getException(Class<T> type)
{code}
/**
* Returns the exception associated with this exchange.
* <p/>
* Is used to get the caused exception that typically have been wrapped in
some sort
* of Camel wrapper exception
* <p/>
* The strategy is to look in the exception hierarchy to find the first
given cause that matches the type.
* Will start from the bottom (the real cause) and walk upwards.
*
* @param type the exception type
* @return the exception (or <tt>null</tt> if no caused exception matched)
*/
<T> T getException(Class<T> type);
{code}
was (Author: njiang):
Collections.reverse(tree) is used to make sure we can get the first cause of
exception in the catch() DSL and ErrorHandler. I will updated the java doc for
it.
> Exchange.getException(Class<T> clazz) returns root cause instead of thrown
> exception
> ------------------------------------------------------------------------------------
>
> Key: CAMEL-7071
> URL: https://issues.apache.org/jira/browse/CAMEL-7071
> Project: Camel
> Issue Type: Bug
> Affects Versions: 2.12.2
> Reporter: Mariusz Lotko
> Assignee: Willem Jiang
>
> If I catch SQLException and wrap it in new MyCoolBuisinessException, then
> Exchange.getException() returns MyCoolBusinessException, but
> Exchange.getException(Exception.class) returns SQLException.
> This impacts ExchangeException annotation which calls
> Exchange.getException(Exception.class).
> Reason for that is in constructor of ObjectUtils.ExceptionIterator which for
> some reason calls Collections.reverse(tree).
--
This message was sent by Atlassian JIRA
(v6.1.4#6159)