Package org.dellroad.stuff.java
Class ThrowableUtil
java.lang.Object
org.dellroad.stuff.java.ThrowableUtil
Utility methods dealing with
Throwables.-
Method Summary
Modifier and TypeMethodDescriptionstatic StackTraceElement[]appendStackFrames(Throwable t, StackTraceElement[] outerFrames) Prepend stack frames from the current thread onto the given exception's stack frames and return the result.static <T extends Throwable>
TMask a checked exception and throw it as an unchecked exception.static voidPrepend stack frames from the current thread onto the given exception's stack frames.
-
Method Details
-
maskException
Mask a checked exception and throw it as an unchecked exception.- Type Parameters:
T- unchecked exception type- Parameters:
t- any exception- Returns:
- never
- Throws:
T- always
-
prependCurrentStackTrace
Prepend stack frames from the current thread onto the given exception's stack frames.This is used to re-throw an exception created in another thread without losing the stack frame information associated with the current thread.
- Parameters:
t- exception from another thread- Throws:
IllegalArgumentException- iftis null
-
appendStackFrames
Prepend stack frames from the current thread onto the given exception's stack frames and return the result.- Parameters:
t- original exceptionouterFrames- stack frames that should wrapt's stack frames- Returns:
- an array containing
t's stack frames, followed byouterFrames - Throws:
IllegalArgumentException- iftorouterFramesis null
-