public class ExceptionUtil extends Object
| Modifier and Type | Field and Description |
|---|---|
static String[] |
unwrapMethods
List of no-arg methods that are known to return a wrapped throwable.
|
| Constructor and Description |
|---|
ExceptionUtil() |
| Modifier and Type | Method and Description |
|---|---|
static Throwable |
baseException(Throwable t)
Get to the base exception (if any).
|
static String |
exceptionFollowedByRootCausesToString(Throwable t)
Utility method for converting an exception and all chained root causes into a
string.
|
static String |
exceptionToString(Throwable t)
Utility method for converting an exception into a string.
|
static String |
getCallAt(Throwable t,
int nth)
Return the "nth" method call from the stack trace of "t", where 0 is
the top.
|
static String |
getStackTraceLines(Throwable t,
int numLines)
return the top n lines of this stack trace.
|
static String |
getStackTraceUpTo(Throwable t,
String prefix)
Return the stack trace up to the first line that starts with prefix.
|
protected static void |
printExceptionStack(Throwable th,
PrintWriter out,
int depth)
Recursively prints out a stack of wrapped exceptions.
|
static String |
toString(Throwable t)
Return the stack trace in a String.
|
static Throwable |
wrappedException(Throwable t)
Get the wrapped Exception object from the Throwable object.
|
public static String[] unwrapMethods
public static Throwable wrappedException(Throwable t)
t - the Throwable objectpublic static Throwable baseException(Throwable t)
t - the Throwable objectpublic static String toString(Throwable t)
t - the Throwable objectpublic static String getStackTraceUpTo(Throwable t, String prefix)
Example: ExceptionUtil.getStackTraceUpTo(exception, "jrunx.");
t - the Throwable objectprefix - the prefix message that we are looking forpublic static String getStackTraceLines(Throwable t, int numLines)
Example: ExceptionUtil.getStackTraceLines(exception, 10);
t - the Throwable objectnumLines - number of lines we should trace downpublic static String getCallAt(Throwable t, int nth)
t - the Throwable objectnth - the line number of the message should we skippublic static String exceptionToString(Throwable t)
t - The throwable exceptionpublic static String exceptionFollowedByRootCausesToString(Throwable t)
exceptionToString(Throwable) which prints the chain
from most nested root cause down to the top-level exception, this method prints
from the top-level exception down to the most nested root cause.t - The throwable exception.protected static void printExceptionStack(Throwable th, PrintWriter out, int depth)
Copyright © 2015 The Apache Software Foundation. All rights reserved.