public class ExceptionUtil
extends java.lang.Object
Constructor and Description |
---|
ExceptionUtil() |
Modifier and Type | Method and Description |
---|---|
static java.lang.String |
buildMessage(java.lang.String message,
java.lang.Throwable cause)
Build a message for the given base message and its cause.
|
static java.lang.String |
exceptionChainToString(java.lang.Throwable t)
Prints full exception stack trace, from top to root cause, into a String.
|
static java.lang.String |
exceptionStackTraceToString(java.lang.Throwable t)
Prints stack trace into a String.
|
static java.lang.Exception |
extractTargetException(java.lang.reflect.InvocationTargetException itex) |
static <T extends java.lang.Throwable> |
findCause(java.lang.Throwable throwable,
java.lang.Class<T> cause)
Finds throwing cause in exception stack.
|
static java.lang.StackTraceElement[] |
getCurrentStackTrace()
Returns current stack trace in form of array of stack trace elements.
|
static java.lang.Throwable[] |
getExceptionChain(java.lang.Throwable throwable)
Returns exception chain starting from top up to root cause.
|
static java.lang.Throwable |
getRootCause(java.lang.Throwable throwable)
Introspects the
Throwable to obtain the root cause. |
static java.lang.StackTraceElement[] |
getStackTrace(java.lang.Throwable t,
java.lang.String[] allow,
java.lang.String[] deny)
Returns stack trace filtered by class names.
|
static java.lang.StackTraceElement[][] |
getStackTraceChain(java.lang.Throwable t,
java.lang.String[] allow,
java.lang.String[] deny)
Returns stack trace chain filtered by class names.
|
static java.lang.String |
message(java.lang.Throwable throwable)
Returns
non-null message for a throwable. |
static java.sql.SQLException |
rollupSqlExceptions(java.util.Collection<java.sql.SQLException> exceptions)
Rolls up SQL exceptions by taking each proceeding exception
and making it a child of the previous using the
setNextException
method of SQLException. |
static void |
throwException(java.lang.Throwable throwable)
Throws checked exceptions in un-checked manner.
|
static void |
throwExceptionAlt(java.lang.Throwable throwable)
Throws checked exceptions in un-checked manner.
|
static void |
throwTargetException(java.lang.reflect.InvocationTargetException itex)
Throws target of
InvocationTargetException if it is exception. |
static java.lang.Throwable |
unwrap(java.lang.Throwable wrapped)
Unwraps invocation and undeclared exceptions to real cause.
|
static java.lang.RuntimeException |
wrapRuntime(java.lang.Throwable throwable)
Wraps exception to
RuntimeException . |
public static java.lang.StackTraceElement[] getCurrentStackTrace()
public static java.lang.StackTraceElement[] getStackTrace(java.lang.Throwable t, java.lang.String[] allow, java.lang.String[] deny)
public static java.lang.StackTraceElement[][] getStackTraceChain(java.lang.Throwable t, java.lang.String[] allow, java.lang.String[] deny)
public static java.lang.Throwable[] getExceptionChain(java.lang.Throwable throwable)
public static java.lang.String exceptionStackTraceToString(java.lang.Throwable t)
public static java.lang.String exceptionChainToString(java.lang.Throwable t)
public static java.lang.String buildMessage(java.lang.String message, java.lang.Throwable cause)
public static java.lang.Throwable getRootCause(java.lang.Throwable throwable)
Throwable
to obtain the root cause.
This method walks through the exception chain to the last element, "root" of the tree, and returns that exception. If no root cause found returns provided throwable.
public static <T extends java.lang.Throwable> T findCause(java.lang.Throwable throwable, java.lang.Class<T> cause)
null
.public static java.sql.SQLException rollupSqlExceptions(java.util.Collection<java.sql.SQLException> exceptions)
setNextException
method of SQLException.public static void throwTargetException(java.lang.reflect.InvocationTargetException itex) throws java.lang.Exception
InvocationTargetException
if it is exception.java.lang.Exception
public static java.lang.Exception extractTargetException(java.lang.reflect.InvocationTargetException itex)
public static void throwExceptionAlt(java.lang.Throwable throwable)
throwException(Throwable)
public static void throwException(java.lang.Throwable throwable)
throwException(Throwable)
public static java.lang.String message(java.lang.Throwable throwable)
non-null
message for a throwable.public static java.lang.RuntimeException wrapRuntime(java.lang.Throwable throwable)
RuntimeException
.public static java.lang.Throwable unwrap(java.lang.Throwable wrapped)
Copyright © 2003-2013 Jodd Team