ExceptionUtilspublic final class ExceptionUtils extends Object The home for utility methods that handle various exception-related tasks. |
Fields Summary |
---|
private static final Method | INIT_CAUSE_METHODA reference to Throwable's initCause method, or null if it's not there in this JVM |
Constructors Summary |
---|
private ExceptionUtils()
|
Methods Summary |
---|
private static java.lang.reflect.Method | getInitCauseMethod()Returns a Method allowing access to
{@link Throwable#initCause(Throwable) initCause} method of {@link Throwable},
or null if the method
does not exist.
try {
Class[] paramsClasses = new Class[] { Throwable.class };
return Throwable.class.getMethod("initCause", paramsClasses);
} catch (NoSuchMethodException e) {
return null;
}
| public static void | initCause(java.lang.Throwable throwable, java.lang.Throwable cause)If we're running on JDK 1.4 or later, initialize the cause for the given throwable.
if (INIT_CAUSE_METHOD != null) {
try {
INIT_CAUSE_METHOD.invoke(throwable, new Object[] { cause });
} catch (Exception e) {
// Well, with no logging, the only option is to munch the exception
}
}
|
|