public final class ExceptionUtils extends Object
| Modifier and Type | Method and Description |
|---|---|
static <T extends Throwable> |
accumulateException(T current,
T extra)
Used to "accumulate" exceptions of the same type.
|
static Throwable |
peelException(Throwable t)
Attempts to get to the "effective" exception being thrown, by taking care of some known exceptions that
wrap the original thrown one.
|
static Throwable |
resolveExceptionCause(Throwable t) |
static void |
rethrowAsIoException(Throwable e) |
static RuntimeException |
toRuntimeException(Throwable t) |
static RuntimeException |
toRuntimeException(Throwable t,
boolean peelThrowable)
Converts a thrown generic exception to a
RuntimeException |
public static void rethrowAsIoException(Throwable e) throws IOException
IOExceptionpublic static <T extends Throwable> T accumulateException(T current, T extra)
null then
the new one becomes the current, otherwise the new one is added as a suppressed exception to the current
oneT - The exception typecurrent - The current exceptionextra - The extra/new exceptionThrowable.addSuppressed(Throwable)public static Throwable resolveExceptionCause(Throwable t)
t - The original Throwable - ignored if nullThrowable.getCause() is non-null then the cause, otherwise the original exception -
null if the original exception was nullpublic static Throwable peelException(Throwable t)
t - The original Throwable - ignored if nullpublic static RuntimeException toRuntimeException(Throwable t, boolean peelThrowable)
RuntimeExceptiont - The original thrown exceptionpeelThrowable - Whether to determine the root cause by "peeling" any enclosing exceptionspeelException(Throwable)public static RuntimeException toRuntimeException(Throwable t)
Copyright © 2018–2021 The Apache Software Foundation. All rights reserved.