java.lang.Object
java.lang.Throwable
java.lang.Exception
java.lang.RuntimeException
dev.metaschema.core.util.ExceptionUtils.WrappedException
- All Implemented Interfaces:
Serializable
- Enclosing class:
- ExceptionUtils
A runtime exception that wraps a checked exception, allowing it to be thrown
from contexts that do not allow checked exceptions (such as lambda
expressions).
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionunwrap()Get the wrapped exception.<E extends Throwable>
EGet the wrapped exception, casting it to the expected type.voidUnwrap and throw the original exception.<E extends Throwable>
voidunwrapAndThrow(Class<E> wrappedExceptionClass) Unwrap and throw the original exception, cast to the expected type.Methods inherited from class java.lang.Throwable
addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
-
Constructor Details
-
WrappedException
Construct a new wrapped exception.- Parameters:
cause- the exception to wrap
-
-
Method Details
-
initCause
-
unwrap
Get the wrapped exception.- Returns:
- the original exception that was wrapped
-
unwrap
Get the wrapped exception, casting it to the expected type.- Type Parameters:
E- the expected exception type- Parameters:
wrappedExceptionClass- the class of the expected exception type- Returns:
- the original exception cast to the expected type
- Throws:
IllegalArgumentException- if the wrapped exception is not of the expected type
-
unwrapAndThrow
Unwrap and throw the original exception.- Throws:
Throwable- the original wrapped exception
-
unwrapAndThrow
Unwrap and throw the original exception, cast to the expected type.- Type Parameters:
E- the expected exception type- Parameters:
wrappedExceptionClass- the class of the expected exception type- Throws:
E- the original wrapped exception cast to the expected type
-