|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.apache.commons.lang.exception.ExceptionUtils
Utility routines for manipulating Throwable
objects.
Field Summary | |
protected static java.lang.String[] |
CAUSE_METHOD_NAMES
The names of methods commonly used to access a wrapped exception. |
protected static java.lang.Object[] |
CAUSE_METHOD_PARAMS
The empty parameter list passed to methods used to access a wrapped exception. |
Constructor Summary | |
protected |
ExceptionUtils()
Constructs a new ExceptionUtils . |
Method Summary | |
static java.lang.Throwable |
getCause(java.lang.Throwable t)
Introspects the specified Throwable for a
getCause() , getNextException() ,
getTargetException() , or
getException() method which returns a
Throwable object (standard as of JDK 1.4, and part
of the NestableException API),
extracting and returning the cause of the exception. |
static java.lang.Throwable |
getCause(java.lang.Throwable t,
java.lang.String[] methodNames)
Extends the API of getCause(Throwable) by
introspecting for only user-specified method names. |
private static java.lang.Throwable |
getCauseUsingFieldName(java.lang.Throwable t,
java.lang.String fieldName)
|
private static java.lang.Throwable |
getCauseUsingMethodName(java.lang.Throwable t,
java.lang.String methodName)
|
private static java.lang.Throwable |
getCauseUsingWellKnownTypes(java.lang.Throwable t)
Uses instanceof checks to examine the exception,
looking for well known types which could contain chained or
wrapped exceptions. |
static java.lang.Throwable |
getRootCause(java.lang.Throwable t)
Walks through the exception chain to the last element -- the "root" of the tree -- using getCause(Throwable) , and
returns that exception. |
(package private) static java.lang.String[] |
getStackFrames(java.lang.String stackTrace)
Functionality shared between the getStackFrames(Throwable) methods of this and the
NestableDelegate
classes. |
static java.lang.String[] |
getStackFrames(java.lang.Throwable t)
Captures the stack trace associated with the specified Throwable object, decomposing it into a list of
stack frames. |
static java.lang.String |
getStackTrace(java.lang.Throwable t)
A convenient way of extracting the stack trace from an exception. |
static int |
getThrowableCount(java.lang.Throwable t)
Returns the number of Throwable objects in the
exception chain. |
static java.lang.Throwable[] |
getThrowables(java.lang.Throwable t)
Returns the list of Throwable objects in the
exception chain. |
static int |
indexOfThrowable(java.lang.Throwable t,
java.lang.Class type)
Delegates to indexOfThrowable(Throwable, Class, int) ,
starting the search at the beginning of the exception chain. |
static int |
indexOfThrowable(java.lang.Throwable t,
java.lang.Class type,
int fromIndex)
Returns the (zero based) index, of the first Throwable that matches the specified type in the
exception chain of Throwable objects with an index
greater than or equal to the specified index, or
-1 if the type is not found. |
Methods inherited from class java.lang.Object |
|
Field Detail |
protected static final java.lang.String[] CAUSE_METHOD_NAMES
protected static final java.lang.Object[] CAUSE_METHOD_PARAMS
Constructor Detail |
protected ExceptionUtils()
ExceptionUtils
. Protected to
discourage instantiation.Method Detail |
public static java.lang.Throwable getCause(java.lang.Throwable t)
Throwable
for a
getCause()
, getNextException()
,
getTargetException()
, or
getException()
method which returns a
Throwable
object (standard as of JDK 1.4, and part
of the NestableException
API),
extracting and returning the cause of the exception. In the
absence of any such method, the object is inspected for a
detail
field assignable to a
Throwable
. If none of the above is found, returns
null
.t
- The exception to introspect for a cause.Throwable
.public static java.lang.Throwable getCause(java.lang.Throwable t, java.lang.String[] methodNames)
getCause(Throwable)
by
introspecting for only user-specified method names.getCause(Throwable)
public static java.lang.Throwable getRootCause(java.lang.Throwable t)
getCause(Throwable)
, and
returns that exception.Throwable
.getCause(Throwable)
private static java.lang.Throwable getCauseUsingWellKnownTypes(java.lang.Throwable t)
instanceof
checks to examine the exception,
looking for well known types which could contain chained or
wrapped exceptions.t
- The exception to examine.null
if not
found.private static java.lang.Throwable getCauseUsingMethodName(java.lang.Throwable t, java.lang.String methodName)
t
- The exception to examine.methodName
- The name of the method to find and invoke.null
if not
found.private static java.lang.Throwable getCauseUsingFieldName(java.lang.Throwable t, java.lang.String fieldName)
t
- The exception to examine.fieldName
- The name of the attribute to examine.null
if not
found.public static int getThrowableCount(java.lang.Throwable t)
Throwable
objects in the
exception chain.t
- The exception to inspect.public static java.lang.Throwable[] getThrowables(java.lang.Throwable t)
Throwable
objects in the
exception chain.t
- The exception to inspect.Throwable
objects.public static int indexOfThrowable(java.lang.Throwable t, java.lang.Class type)
indexOfThrowable(Throwable, Class, int)
,
starting the search at the beginning of the exception chain.indexOfThrowable(Throwable, Class, int)
public static int indexOfThrowable(java.lang.Throwable t, java.lang.Class type, int fromIndex)
Throwable
that matches the specified type in the
exception chain of Throwable
objects with an index
greater than or equal to the specified index, or
-1
if the type is not found.t
- The exception to inspect.type
- Class
to look for.fromIndex
- The (zero based) index of the starting
position in the chain to be searched.-1
if the type is not found.IndexOutOfBoundsException
- If the fromIndex
argument is negative or not less than the count of
Throwable
s in the chain.public static java.lang.String getStackTrace(java.lang.Throwable t)
t
- The Throwable
.printStackTrace(PrintWriter)
method.public static java.lang.String[] getStackFrames(java.lang.Throwable t)
Throwable
object, decomposing it into a list of
stack frames.t
- The Throwable
.static java.lang.String[] getStackFrames(java.lang.String stackTrace)
getStackFrames(Throwable)
methods of this and the
NestableDelegate
classes.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |