Package org.apache.avalon.framework
Class ExceptionUtil
java.lang.Object
org.apache.avalon.framework.ExceptionUtil
This class provides basic facilities for manipulating exceptions.
Some exception handling stuff thieved from Turbine...
- Version:
- CVS $Revision: 1.25 $ $Date: 2004/02/11 14:34:25 $
- Author:
- Avalon Development Team
-
Method Summary
Modifier and TypeMethodDescriptionstatic String[]
captureStackTrace
(Throwable throwable) Captures the stack trace associated with this exception.static Throwable
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 specifiedThrowable
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) Deprecated.This is an internal utility method that should not be used
-
Method Details
-
printStackTrace
Generate string for specified exception and the cause of this exception (if any).- Parameters:
throwable
- aThrowable
- Returns:
- the stack trace as a
String
-
printStackTrace
Generate string for specified exception and if printCascading is true will print all cascading exceptions.- Parameters:
throwable
- aThrowable
printCascading
- iftrue
will print all cascading exceptions- Returns:
- the stack trace as a
String
-
printStackTrace
Serialize the specifiedThrowable
to a string. Restrict the number of frames printed out to the specified depth. If the depth specified is0
then all the frames are converted into a string.- Parameters:
throwable
- aThrowable
depth
- number of stack trace frames to show- Returns:
- the stack trace as a
String
-
printStackTrace
Generate exception string for specified exception to specified depth and all Cascading exceptions if printCascading is true.- Parameters:
throwable
- aThrowable
depth
- number of stack trace frames to showprintCascading
- iftrue
will print all cascading exceptions- Returns:
- 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 signatureThrowable getCause()
. This makes it compatible with JDK1.4 mechanisms for nesting exceptions.- Parameters:
throwable
- aThrowable
depth
- number of stack trace frames to showprintCascading
- iftrue
will print all cascading exceptionsuseReflection
- iftrue
will use reflection to handle JDK1.4 nested exceptions- Returns:
- the stack trace as a
String
-
getCause
Utility method to get cause of exception.- Parameters:
throwable
- aThrowable
useReflection
- iftrue
will use reflection to handle JDK1.4 nested exceptions- Returns:
- cause of specified exception
-
captureStackTrace
Captures the stack trace associated with this exception.- Parameters:
throwable
- aThrowable
- Returns:
- an array of Strings describing stack frames.
-
splitString
Deprecated.This is an internal utility method that should not be usedSplits the string on every token into an array of stack frames.- Parameters:
string
- the string to splitonToken
- the token to split on- Returns:
- the resultant array
-