public final class Exceptions
extends java.lang.Object
Modifier and Type | Method and Description |
---|---|
static void |
addCause(java.lang.Throwable e,
java.lang.Throwable cause)
Adds a
Throwable to a causality-chain of Throwables, as an additional cause (if it does not
already appear in the chain among the causes). |
static java.lang.Throwable |
getFinalCause(java.lang.Throwable e)
Get the
Throwable at the end of the causality-chain for a particular Throwable |
static java.lang.RuntimeException |
propagate(java.lang.Throwable t) |
static void |
throwIfFatal(java.lang.Throwable t)
Throws a particular
Throwable only if it belongs to a set of "fatal" error varieties. |
public static java.lang.RuntimeException propagate(java.lang.Throwable t)
propagate
itself throws an exception or error, this is a sort of phantom return
value; propagate
does not actually return anythingpublic static void throwIfFatal(java.lang.Throwable t)
Throwable
only if it belongs to a set of "fatal" error varieties. These
varieties are as follows:
OnErrorNotImplementedException
OnErrorFailedException
StackOverflowError
VirtualMachineError
ThreadDeath
LinkageError
onError
methods, but only
if the errors are not so catastrophic that such a call would be futile, in which case you simply want to
rethrow the error.t
- the Throwable
to test and perhaps throwpublic static void addCause(java.lang.Throwable e, java.lang.Throwable cause)
Throwable
to a causality-chain of Throwables, as an additional cause (if it does not
already appear in the chain among the causes).e
- the Throwable
at the head of the causality chaincause
- the Throwable
you want to add as a cause of the chainpublic static java.lang.Throwable getFinalCause(java.lang.Throwable e)
Throwable
at the end of the causality-chain for a particular Throwable
e
- the Throwable
whose final cause you are curious aboutThrowable
in the causality-chain of e
(or a "Stack too deep to get
final cause" RuntimeException
if the chain is too long to traverse)