Package org.apache.avalon.framework
Class ExceptionUtil
- java.lang.Object
-
- org.apache.avalon.framework.ExceptionUtil
-
public final class ExceptionUtil extends java.lang.ObjectThis class provides basic facilities for manipulating exceptions. Some exception handling stuff thieved from Turbine...- Author:
- Avalon Development Team
-
-
Field Summary
Fields Modifier and Type Field Description private static java.lang.StringGET_CAUSE_NAMEprivate static java.lang.Class[]GET_CAUSE_PARAMTYPESprivate static java.lang.StringLINE_SEPARATOR
-
Constructor Summary
Constructors Modifier Constructor Description privateExceptionUtil()Private constructor to prevent instantiation.
-
Method Summary
All Methods Static Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static java.lang.String[]captureStackTrace(java.lang.Throwable throwable)Captures the stack trace associated with this exception.static java.lang.ThrowablegetCause(java.lang.Throwable throwable, boolean useReflection)Utility method to get cause of exception.static java.lang.StringprintStackTrace(java.lang.Throwable throwable)Generate string for specified exception and the cause of this exception (if any).static java.lang.StringprintStackTrace(java.lang.Throwable throwable, boolean printCascading)Generate string for specified exception and if printCascading is true will print all cascading exceptions.static java.lang.StringprintStackTrace(java.lang.Throwable throwable, int depth)Serialize the specifiedThrowableto a string.static java.lang.StringprintStackTrace(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.StringprintStackTrace(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.static java.lang.String[]splitString(java.lang.String string, java.lang.String onToken)Deprecated.This is an internal utility method that should not be usedprivate static java.lang.String[]splitStringInternal(java.lang.String string, java.lang.String onToken)Splits the string on every token into an array of stack frames.
-
-
-
Field Detail
-
LINE_SEPARATOR
private static final java.lang.String LINE_SEPARATOR
-
GET_CAUSE_NAME
private static final java.lang.String GET_CAUSE_NAME
- See Also:
- Constant Field Values
-
GET_CAUSE_PARAMTYPES
private static final java.lang.Class[] GET_CAUSE_PARAMTYPES
-
-
Method Detail
-
printStackTrace
public static java.lang.String printStackTrace(java.lang.Throwable throwable)
Generate string for specified exception and the cause of this exception (if any).- Parameters:
throwable- aThrowable- Returns:
- the stack trace as a
String
-
printStackTrace
public 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.- Parameters:
throwable- aThrowableprintCascading- iftruewill print all cascading exceptions- Returns:
- the stack trace as a
String
-
printStackTrace
public static java.lang.String printStackTrace(java.lang.Throwable throwable, int depth)Serialize the specifiedThrowableto a string. Restrict the number of frames printed out to the specified depth. If the depth specified is0then all the frames are converted into a string.- Parameters:
throwable- aThrowabledepth- number of stack trace frames to show- Returns:
- the stack trace as a
String
-
printStackTrace
public 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.- Parameters:
throwable- aThrowabledepth- number of stack trace frames to showprintCascading- iftruewill print all cascading exceptions- Returns:
- the stack trace as a
String
-
printStackTrace
public 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. 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- aThrowabledepth- number of stack trace frames to showprintCascading- iftruewill print all cascading exceptionsuseReflection- iftruewill use reflection to handle JDK1.4 nested exceptions- Returns:
- the stack trace as a
String
-
getCause
public static java.lang.Throwable getCause(java.lang.Throwable throwable, boolean useReflection)Utility method to get cause of exception.- Parameters:
throwable- aThrowableuseReflection- iftruewill use reflection to handle JDK1.4 nested exceptions- Returns:
- cause of specified exception
-
captureStackTrace
public static java.lang.String[] captureStackTrace(java.lang.Throwable throwable)
Captures the stack trace associated with this exception.- Parameters:
throwable- aThrowable- Returns:
- an array of Strings describing stack frames.
-
splitString
public static java.lang.String[] splitString(java.lang.String string, java.lang.String onToken)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
-
splitStringInternal
private static java.lang.String[] splitStringInternal(java.lang.String string, java.lang.String onToken)Splits 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
-
-