Details
-
Improvement
-
Status: Closed
-
Minor
-
Resolution: Fixed
-
None
-
None
-
None
-
Operating System: other
Platform: Other
-
37574
Description
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.