public final class ExceptionHelper extends Object
Modifier and Type | Field and Description |
---|---|
static Throwable |
TERMINATED
A singleton instance of a Throwable indicating a terminal state for exceptions,
don't leak this.
|
Modifier and Type | Method and Description |
---|---|
static <T> boolean |
addThrowable(AtomicReference<Throwable> field,
Throwable exception) |
static List<Throwable> |
flatten(Throwable t)
Returns a flattened list of Throwables from tree-like CompositeException chain.
|
static <T> Throwable |
terminate(AtomicReference<Throwable> field) |
static <E extends Throwable> |
throwIfThrowable(Throwable e)
Workaround for Java 6 not supporting throwing a final Throwable from a catch block.
|
static String |
timeoutMessage(long timeout,
TimeUnit unit) |
static RuntimeException |
wrapOrThrow(Throwable error)
If the provided Throwable is an Error this method
throws it, otherwise returns a RuntimeException wrapping the error
if that error is a checked exception.
|
public static final Throwable TERMINATED
public static RuntimeException wrapOrThrow(Throwable error)
error
- the error to wrap or throwpublic static <T> boolean addThrowable(AtomicReference<Throwable> field, Throwable exception)
public static <T> Throwable terminate(AtomicReference<Throwable> field)
public static List<Throwable> flatten(Throwable t)
t
- the starting throwablepublic static <E extends Throwable> Exception throwIfThrowable(Throwable e) throws E extends Throwable
E
- the generic exception typee
- the Throwable error to return or throwE
- the generic exception thrownE extends Throwable
Copyright © 2019. All rights reserved.