Package com.landawn.abacus.util
Class ExceptionUtil
java.lang.Object
com.landawn.abacus.util.ExceptionUtil
Note: This class contains the methods copied from Apache Commons and Google Guava under Apache License v2.
-
Method Summary
Modifier and TypeMethodDescriptionstatic Throwable
firstCause
(Throwable throwable) Returns the specifiedthrowable
if there is no cause found in it (throwable.getCause() == null
).static String
static String
getErrorMessage
(Throwable e, boolean withExceptionClassName) static String
Deprecated.replaced by {@link #getErrorMessage(Throwable, true)}static String
getStackTrace
(Throwable throwable) Gets the stack trace from a Throwable as a String.static boolean
static boolean
static boolean
hasIOCause
(Throwable throwable) static boolean
hasSQLCause
(Throwable throwable) static <E extends Throwable>
voidregisterRuntimeExceptionMapper
(Class<E> exceptionClass, Function<E, RuntimeException> runtimeExceptionMapper) static <E extends Throwable>
voidregisterRuntimeExceptionMapper
(Class<E> exceptionClass, Function<E, RuntimeException> runtimeExceptionMapper, boolean force) static RuntimeException
static RuntimeException
To runtime exception.static Exception
-
Method Details
-
registerRuntimeExceptionMapper
public static <E extends Throwable> void registerRuntimeExceptionMapper(Class<E> exceptionClass, Function<E, RuntimeException> runtimeExceptionMapper) - Type Parameters:
E
-- Parameters:
exceptionClass
-runtimeExceptionMapper
-
-
registerRuntimeExceptionMapper
public static <E extends Throwable> void registerRuntimeExceptionMapper(Class<E> exceptionClass, Function<E, RuntimeException> runtimeExceptionMapper, boolean force) - Type Parameters:
E
-- Parameters:
exceptionClass
-runtimeExceptionMapper
-force
-
-
toRuntimeException
To runtime exception.- Parameters:
e
-- Returns:
- See Also:
-
toRuntimeException
-
tryToGetOriginalCheckedException
-
hasCause
-
hasCause
-
hasSQLCause
-
hasIOCause
-
listCause
-
firstCause
Returns the specifiedthrowable
if there is no cause found in it (throwable.getCause() == null
).- Parameters:
throwable
-- Returns:
-
getStackTrace
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
-
getMessage
Deprecated.replaced by {@link #getErrorMessage(Throwable, true)}Gets the error msg.- Parameters:
e
-- Returns:
-
getErrorMessage
-
getErrorMessage
-