You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by bu...@apache.org on 2005/11/21 00:30:52 UTC

DO NOT REPLY [Bug 37574] New: - [lang] [PATCH] new ExceptionUtils.setCause() method

DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG�
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=37574>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND�
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=37574

           Summary: [lang] [PATCH] new ExceptionUtils.setCause() method
           Product: Commons
           Version: 1.4 Final
          Platform: Other
        OS/Version: other
            Status: NEW
          Severity: enhancement
          Priority: P2
         Component: Lang
        AssignedTo: commons-dev@jakarta.apache.org
        ReportedBy: andrea.rombaldi@alice.it


Hi people,

the purpose of the ExceptionUtils.setCause() method I am proposing is to 
preserve the standard JDK 1.4 exception 

nesting mechanism even when targeting source code for a prior JDK 1.4 version.

ExceptionUtils.setCause(), which can be thought as the counterpart of 
ExceptionUtils.getCause(), calls via 

introspection on the target Throwable the 2 following methods: 

<Object>.setCause(Throwable)
<Object>.initCause(Throwable)

The typical use of ExceptionUtils.setCause() is inside a constructor, as in 
the following example:


import org.apache.commons.lang.exception.ExceptionUtils;

public class MyException extends Exception {

  public MyException(String msg) {
    super(msg);
  }

  public MyException(String msg, Throwable cause) {
    super(msg);
    ExceptionUtils.setCause(this, cause);
  }

}      


I hope this can be useful for whom who are maintaining code that must be 
portable on both the JDK 1.3 and JDK 1.4+ 

environments.

Andrea.

-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org