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
IOException
public 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 null
Throwable.getCause()
is non-null
then the cause, otherwise the original exception -
null
if the original exception was null
public static Throwable peelException(Throwable t)
t
- The original Throwable
- ignored if null
public static RuntimeException toRuntimeException(Throwable t, boolean peelThrowable)
RuntimeException
t
- The original thrown exceptionpeelThrowable
- Whether to determine the root cause by "peeling" any enclosing exceptionspeelException(Throwable)
public static RuntimeException toRuntimeException(Throwable t)
Copyright © 2008–2024 The Apache Software Foundation. All rights reserved.