[ 
https://issues.apache.org/jira/browse/QPID-1434?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12645508#action_12645508
 ] 

Rafael H. Schloming commented on QPID-1434:
-------------------------------------------

Sorry to comment late on this.

I disagree that the only use case for this is when passing an exception across 
threads. This pattern should be used whenever there is any significant code or 
computation occurring between the original exception and the point where the 
rethrow occurs, and arguably we should just use it all the time when rethrowing 
an exception. Passing an exception across threads is only one example of when 
this should be used.

I also think returning the exception rather than throwing it directly somewhat 
defeats the point of the pattern since it permits you to do even more 
computation between the point where the exception is constructed (and hence the 
stack trace reported) and where it is actually thrown.

Given this I think rethrow() is a perfectly reasonable name choice given that 
the pattern is supposed to be used as a general substitute for throw e; or 
throw new GenericException(e);, both of which lose important information. 
Certainly cloneForCurrentThread() seems potentially damaging as a name since it 
may discourage people from using it when threads aren't involved.

> Add ability to rethrow an AMQException
> --------------------------------------
>
>                 Key: QPID-1434
>                 URL: https://issues.apache.org/jira/browse/QPID-1434
>             Project: Qpid
>          Issue Type: Improvement
>          Components: Java Common
>    Affects Versions: M3
>            Reporter: Martin Ritchie
>            Assignee: Rob Godfrey
>             Fix For: M4
>
>
> Summary:
> When we receive an exception we often simply rethrow by performing:
> throw receivedException;
> However this makes debugging difficult as the stack trace reflects the 
> original point where this exception occurred.
> Adding the ability to perform:
> receivedException.rethrow();
> As has been done to the TransportException in the 0-10 IO Transport layer 
> will allow us to improve our error reporting.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to