public final class ExceptionUtil extends Object
Modifier and Type | Method and Description |
---|---|
static String |
getMessage(Throwable e)
Gets the error msg.
|
static String |
getStackTrace(Throwable throwable)
Gets the stack trace from a Throwable as a String.
|
static boolean |
hasCause(Throwable chain,
Class<? extends Throwable> type)
Does the throwable's causal chain have an immediate or wrapped exception
of the given type?
|
static RuntimeException |
toRuntimeException(Throwable e)
To runtime exception.
|
public static RuntimeException toRuntimeException(Throwable e)
e
- public static String getMessage(Throwable e)
e
- public static String getStackTrace(Throwable throwable)
Gets the stack trace from a Throwable as a String.
The result of this method vary by JDK version as this method
uses Throwable.printStackTrace(java.io.PrintWriter)
.
On JDK1.3 and earlier, the cause exception will not be shown
unless the specified throwable alters printStackTrace.
throwable
- the Throwable
to be examinedprintStackTrace(PrintWriter)
methodpublic static boolean hasCause(Throwable chain, Class<? extends Throwable> type)
chain
- The root of a Throwable causal chain.type
- The exception type to test.#wrapAndThrow(Throwable)
Copyright © 2020. All rights reserved.