public final class ExceptionUtil
extends java.lang.Object
Modifier and Type | Method and Description |
---|---|
static java.lang.String[] |
captureStackTrace(java.lang.Throwable throwable)
Captures the stack trace associated with this exception.
|
static java.lang.Throwable |
getCause(java.lang.Throwable throwable,
boolean useReflection)
Utility method to get cause of exception.
|
static java.lang.String |
getMessage(java.lang.Throwable t)
Returns the message of a throwable or the class name if the message is
null or empty.
|
static java.lang.String |
printStackTrace(java.lang.Throwable throwable)
Generate string for specified exception and the cause of
this exception (if any).
|
static java.lang.String |
printStackTrace(java.lang.Throwable throwable,
boolean printCascading)
Generate string for specified exception and if printCascading
is true will print all cascading exceptions.
|
static java.lang.String |
printStackTrace(java.lang.Throwable throwable,
int depth)
Serialize the specified
Throwable to a string. |
static java.lang.String |
printStackTrace(java.lang.Throwable throwable,
int depth,
boolean printCascading)
Generate exception string for specified exception to specified depth
and all Cascading exceptions if printCascading is true.
|
static java.lang.String |
printStackTrace(java.lang.Throwable throwable,
int depth,
boolean printCascading,
boolean useReflection)
Generate exception string for specified exception to specified depth
and all Cascading exceptions if printCascading is true.
|
public static java.lang.String printStackTrace(java.lang.Throwable throwable)
throwable
- a Throwable
String
public static java.lang.String printStackTrace(java.lang.Throwable throwable, boolean printCascading)
throwable
- a Throwable
printCascading
- if true
will print all cascading
exceptionsString
public static java.lang.String printStackTrace(java.lang.Throwable throwable, int depth)
Throwable
to a string.
Restrict the number of frames printed out to the specified depth.
If the depth specified is 0
then all the frames are
converted into a string.throwable
- a Throwable
depth
- number of stack trace frames to showString
public static java.lang.String printStackTrace(java.lang.Throwable throwable, int depth, boolean printCascading)
throwable
- a Throwable
depth
- number of stack trace frames to showprintCascading
- if true
will print all cascading
exceptionsString
public static java.lang.String printStackTrace(java.lang.Throwable throwable, int depth, boolean printCascading, boolean useReflection)
Throwable getCause()
. This makes
it compatible with JDK1.4 mechanisms for nesting exceptions.throwable
- a Throwable
depth
- number of stack trace frames to showprintCascading
- if true
will print all cascading
exceptionsuseReflection
- if true
will use reflection to handle
JDK1.4 nested exceptionsString
public static java.lang.Throwable getCause(java.lang.Throwable throwable, boolean useReflection)
throwable
- a Throwable
useReflection
- if true
will use reflection to handle
JDK1.4 nested exceptionspublic static java.lang.String[] captureStackTrace(java.lang.Throwable throwable)
throwable
- a Throwable
public static java.lang.String getMessage(java.lang.Throwable t)
t
- any throwableSubmit a
bug or a
feature.
Created by
xsddoc, a sub project of
xframe, hosted at
http://www.sourceforge.net.