Package com.landawn.abacus.util
Class ExceptionUtil
- java.lang.Object
-
- com.landawn.abacus.util.ExceptionUtil
-
public final class ExceptionUtil extends Object
Note: This class contains the methods copied from Apache Commons and Google Guava under Apache License v2.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method 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.
-
-
-
Method Detail
-
toRuntimeException
public static RuntimeException toRuntimeException(Throwable e)
To runtime exception.- Parameters:
e
-- Returns:
-
getMessage
public static String getMessage(Throwable e)
Gets the error msg.- Parameters:
e
-- Returns:
-
getStackTrace
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.- Parameters:
throwable
- theThrowable
to be examined- Returns:
printStackTrace(PrintWriter)
method
-
hasCause
public 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?- Parameters:
chain
- The root of a Throwable causal chain.type
- The exception type to test.- Returns:
- true, if chain is an instance of type or is an UndeclaredThrowableException wrapping a cause.
- Since:
- 3.5
- See Also:
#wrapAndThrow(Throwable)
-
-