Package io.vertigo.core.lang
Class WrappedException
- java.lang.Object
-
- java.lang.Throwable
-
- java.lang.Exception
-
- java.lang.RuntimeException
-
- io.vertigo.core.lang.WrappedException
-
- All Implemented Interfaces:
Serializable
public final class WrappedException extends RuntimeException
Encapsulates checked Exception inside a RuntimeException. Inspired by gnu.mapping.WrappedException.- Author:
- npiedeloup
- See Also:
- Serialized Form
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Throwable
unwrap()
Gets the orginal exception.static RuntimeException
wrap(Throwable th)
Coerces argument to a RuntimeException.static RuntimeException
wrap(Throwable th, String msg, Object... params)
Coerces argument to a RuntimeException.-
Methods inherited from class java.lang.Throwable
addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
-
-
-
-
Method Detail
-
wrap
public static RuntimeException wrap(Throwable th)
Coerces argument to a RuntimeException. Re-throws as a non-checked exception. This method never returns, in spite of the return type. This allows the call to be written as: throw WrappedExcepton.rethrow(th) so javac and the verifier can know the code doesn't return.- Parameters:
th
- Cause exception- Returns:
- RuntimeException runtime
-
wrap
public static RuntimeException wrap(Throwable th, String msg, Object... params)
Coerces argument to a RuntimeException. Re-throw as a non-checked exception. This method never returns, in spite of the return type. This allows the call to be written as: throw WrappedExcepton.rethrow(th) so javac and the verifier can know the code doesn't return.- Parameters:
th
- Cause exceptionmsg
- Context messageparams
- Context message params- Returns:
- RuntimeException runtime
-
unwrap
public Throwable unwrap()
Gets the orginal exception.- Returns:
- the orginal exception that has been wrapped
-
-