Package org.apache.sshd.common.util
Class ExceptionUtils
- java.lang.Object
-
- org.apache.sshd.common.util.ExceptionUtils
-
public final class ExceptionUtils extends java.lang.Object
-
-
Constructor Summary
Constructors Modifier Constructor Description privateExceptionUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <T extends java.lang.Throwable>
TaccumulateException(T current, T extra)Used to "accumulate" exceptions of the same type.static java.lang.ThrowablepeelException(java.lang.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 java.lang.ThrowableresolveExceptionCause(java.lang.Throwable t)static voidrethrowAsIoException(java.lang.Throwable e)static java.lang.RuntimeExceptiontoRuntimeException(java.lang.Throwable t)static java.lang.RuntimeExceptiontoRuntimeException(java.lang.Throwable t, boolean peelThrowable)Converts a thrown generic exception to aRuntimeException
-
-
-
Method Detail
-
rethrowAsIoException
public static void rethrowAsIoException(java.lang.Throwable e) throws java.io.IOException- Throws:
java.io.IOException
-
accumulateException
public static <T extends java.lang.Throwable> T accumulateException(T current, T extra)Used to "accumulate" exceptions of the same type. If the current exception isnullthen the new one becomes the current, otherwise the new one is added as a suppressed exception to the current one- Type Parameters:
T- The exception type- Parameters:
current- The current exceptionextra- The extra/new exception- Returns:
- The resolved exception
- See Also:
Throwable.addSuppressed(Throwable)
-
resolveExceptionCause
public static java.lang.Throwable resolveExceptionCause(java.lang.Throwable t)
- Parameters:
t- The originalThrowable- ignored ifnull- Returns:
- If
Throwable.getCause()is non-nullthen the cause, otherwise the original exception -nullif the original exception wasnull
-
peelException
public static java.lang.Throwable peelException(java.lang.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- The originalThrowable- ignored ifnull- Returns:
- The effective exception - same as input if not a wrapper
-
toRuntimeException
public static java.lang.RuntimeException toRuntimeException(java.lang.Throwable t, boolean peelThrowable)Converts a thrown generic exception to aRuntimeException- Parameters:
t- The original thrown exceptionpeelThrowable- Whether to determine the root cause by "peeling" any enclosing exceptions- Returns:
- The thrown cause if already a runtime exception, otherwise a runtime exception of the resolved exception as its cause
- See Also:
peelException(Throwable)
-
toRuntimeException
public static java.lang.RuntimeException toRuntimeException(java.lang.Throwable t)
-
-