public class ExceptionHelper extends Object
Helper class for handling exception nesting, which is only supported in JDKs which are version 1.4 or later.
Sample usage:
try {
// Validate arguments
} catch (Exception e) {
Exception myException = new IllegalArgumentException("Doh!");
ExceptionHelper.setCause(myException, e);
throw myException;
}
| Modifier and Type | Method and Description |
|---|---|
static Throwable |
getCause(Throwable exception)
Get the underlying cause
Throwable of the given exception
if this JDK supports the Throwable#getCause() method. |
static Throwable |
setCause(Throwable exception,
Throwable cause)
Set the given
Throwable |
static boolean |
supportsNestedThrowable()
Get whether the Throwable hierarchy for this JDK supports
initCause()/getCause().
|
public static Throwable setCause(Throwable exception, Throwable cause)
Throwable's cause if this JDK supports
the Throwable#initCause(Throwable) method.public static Throwable getCause(Throwable exception)
Throwable of the given exception
if this JDK supports the Throwable#getCause() method.public static boolean supportsNestedThrowable()
Copyright © 2014. All rights reserved.