Class ExceptionUtil
java.lang.Object
jodd.exception.ExceptionUtil
Few exception utilities.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic StringbuildMessage(String message, Throwable cause) Build a message for the given base message and its cause.static StringPrints full exception stack trace, from top to root cause, into a String.static StringPrints stack trace into a String.static <T extends Throwable>
TFinds throwing cause in exception stack.static StackTraceElement[]Returns current stack trace in form of array of stack trace elements.static Throwable[]getExceptionChain(Throwable throwable) Returns exception chain starting from top up to root cause.static ThrowablegetRootCause(Throwable throwable) Introspects theThrowableto obtain the root cause.static StackTraceElement[]getStackTrace(Throwable t, String[] allow, String[] deny) Returns stack trace filtered by class names.static StackTraceElement[][]getStackTraceChain(Throwable t, String[] allow, String[] deny) Returns stack trace chain filtered by class names.static StringReturnsnon-nullmessage for a throwable.static SQLExceptionrollupSqlExceptions(Collection<SQLException> exceptions) Rolls up SQL exceptions by taking each proceeding exception and making it a child of the previous using thesetNextExceptionmethod of SQLException.static voidthrowRuntimeException(Throwable throwable) Throws checked exceptions in un-checked manner.static ThrowableunwrapThrowable(Throwable wrappedThrowable) Unwraps invocation and undeclared exceptions to real cause.static ExceptionwrapToException(Throwable throwable) static RuntimeExceptionwrapToRuntimeException(Throwable throwable) Wraps exception toRuntimeException.
-
Constructor Details
-
ExceptionUtil
public ExceptionUtil()
-
-
Method Details
-
getCurrentStackTrace
Returns current stack trace in form of array of stack trace elements. First stack trace element is removed. Since an exception is thrown internally, this method is slow. -
getStackTrace
Returns stack trace filtered by class names. -
getStackTraceChain
Returns stack trace chain filtered by class names. -
getExceptionChain
-
exceptionStackTraceToString
-
exceptionChainToString
-
buildMessage
-
getRootCause
-
findCause
-
rollupSqlExceptions
Rolls up SQL exceptions by taking each proceeding exception and making it a child of the previous using thesetNextExceptionmethod of SQLException. -
throwRuntimeException
Throws checked exceptions in un-checked manner. -
message
-
wrapToRuntimeException
Wraps exception toRuntimeException. -
wrapToException
-
unwrapThrowable
-