org.apache.avalon.framework
Class ExceptionUtil
java.lang.Object
org.apache.avalon.framework.ExceptionUtil
public final class ExceptionUtil
extends java.lang.Object
This class provides basic facilities for manipulating exceptions.
Some exception handling stuff thieved from Turbine...
Version:
- Avalon Development Team
static String[] | captureStackTrace(Throwable throwable) - Captures the stack trace associated with this exception.
|
static Throwable | getCause(Throwable throwable, boolean useReflection) - Utility method to get cause of exception.
|
static String | printStackTrace(Throwable throwable) - Generate string for specified exception and the cause of
this exception (if any).
|
static String | printStackTrace(Throwable throwable, boolean printCascading) - Generate string for specified exception and if printCascading
is true will print all cascading exceptions.
|
static String | printStackTrace(Throwable throwable, int depth) - Serialize the specified
Throwable to a string.
|
static String | printStackTrace(Throwable throwable, int depth, boolean printCascading) - Generate exception string for specified exception to specified depth
and all Cascading exceptions if printCascading is true.
|
static String | printStackTrace(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.
|
static String[] | splitString(String string, String onToken) - This is an internal utility method that should not be used
|
captureStackTrace
public static String[] captureStackTrace(Throwable throwable)
Captures the stack trace associated with this exception.
throwable
- a Throwable
- an array of Strings describing stack frames.
getCause
public static Throwable getCause(Throwable throwable,
boolean useReflection)
Utility method to get cause of exception.
throwable
- a Throwable
useReflection
- if true
will use reflection to handle JDK1.4
nested exceptions
- cause of specified exception
printStackTrace
public static String printStackTrace(Throwable throwable)
Generate string for specified exception and the cause of
this exception (if any).
throwable
- a Throwable
- the stack trace as a
String
printStackTrace
public static String printStackTrace(Throwable throwable,
boolean printCascading)
Generate string for specified exception and if printCascading
is true will print all cascading exceptions.
throwable
- a Throwable
printCascading
- if true
will print all cascading exceptions
- the stack trace as a
String
printStackTrace
public static String printStackTrace(Throwable throwable,
int depth)
Serialize the specified 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 show
- the stack trace as a
String
printStackTrace
public static String printStackTrace(Throwable throwable,
int depth,
boolean printCascading)
Generate exception string for specified exception to specified depth
and all Cascading exceptions if printCascading is true.
throwable
- a Throwable
depth
- number of stack trace frames to showprintCascading
- if true
will print all cascading exceptions
- the stack trace as a
String
printStackTrace
public static String printStackTrace(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. If useReflection
is true then the method will also attempt to use reflection to find a
method with signature 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 exceptions
- the stack trace as a
String
splitString
public static String[] splitString(String string,
String onToken)
This is an internal utility method that should not be used
Splits the string on every token into an array of stack frames.
string
- the string to splitonToken
- the token to split on
- the resultant array
"Copyright B) 2001 Apache Jakarta Project. All Rights Reserved."