Top Constructors Methods
org.apache.sshd.common.util

public final Class ExceptionUtils

extends Object
Class Inheritance
Imports
java.io.IOException, java.lang.reflect.InvocationTargetException, .UndeclaredThrowableException, java.util.concurrent.ExecutionException, javax.management.MBeanException, .ReflectionException

Author
Apache MINA SSHD Project

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static <
The exception type
T extends Throwable
>
T

Returns:

The resolved exception
accumulateException
(T
The current exception
current
,
T
The extra/new exception
extra
)

Used to "accumulate" exceptions of the same type.

public static Throwable

Returns:

The effective exception - same as input if not a wrapper
peelException
(Throwable
The original Throwable - ignored if null
t
)

Attempts to get to the "effective" exception being thrown, by taking care of some known exceptions that wrap the original thrown one.

public static Throwable

Returns:

If Throwable#getCause() is non-null then the cause, otherwise the original exception - null if the original exception was null
resolveExceptionCause
(Throwable
The original Throwable - ignored if null
t
)

public static void
public static RuntimeException

Returns:

The thrown cause if already a runtime exception, otherwise a runtime exception of the resolved exception as its cause
toRuntimeException
(Throwable
The original thrown exception
t
,
boolean
Whether to determine the root cause by "peeling" any enclosing exceptions
peelThrowable
)

Converts a thrown generic exception to a RuntimeException

public static RuntimeException
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

ExceptionUtilsback to summary
private ExceptionUtils()

Method Detail

accumulateExceptionback to summary
public static <T extends Throwable> T accumulateException(T current, T extra)

Used to "accumulate" exceptions of the same type. If the current exception is null then the new one becomes the current, otherwise the new one is added as a suppressed exception to the current one

Parameters
<T>
The exception type
current:T

The current exception

extra:T

The extra/new exception

Returns:T

The resolved exception

See Also
Throwable#addSuppressed(Throwable)
peelExceptionback to summary
public 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.

Parameters
t:Throwable

The original Throwable - ignored if null

Returns:Throwable

The effective exception - same as input if not a wrapper

resolveExceptionCauseback to summary
public static Throwable resolveExceptionCause(Throwable t)
Parameters
t:Throwable

The original Throwable - ignored if null

Returns:Throwable

If Throwable#getCause() is non-null then the cause, otherwise the original exception - null if the original exception was null

rethrowAsIoExceptionback to summary
public static void rethrowAsIoException(Throwable e) throws IOException
toRuntimeExceptionback to summary
public static RuntimeException toRuntimeException(Throwable t, boolean peelThrowable)

Converts a thrown generic exception to a RuntimeException

Parameters
t:Throwable

The original thrown exception

peelThrowable:boolean

Whether to determine the root cause by "peeling" any enclosing exceptions

Returns:RuntimeException

The thrown cause if already a runtime exception, otherwise a runtime exception of the resolved exception as its cause

See Also
peelException(Throwable)
toRuntimeExceptionback to summary
public static RuntimeException toRuntimeException(Throwable t)