public class Exceptions
extends java.lang.Object
Constructor and Description |
---|
Exceptions() |
Modifier and Type | Method and Description |
---|---|
static java.lang.Throwable |
collapse(java.lang.Throwable source)
creates (but does not throw) a new
PropagatedRuntimeException whose
message and cause are taken from the first _interesting_ element in the source |
static java.lang.Throwable |
collapse(java.lang.Throwable source,
boolean collapseCausalChain)
creates (but does not throw) a new
PropagatedRuntimeException whose
message is taken from the first _interesting_ element in the source,
and optionally also the causal chain |
static java.lang.Throwable |
collapseIncludingAllCausalMessages(java.lang.Throwable source)
as
collapse(Throwable) but includes causal messages in the message as per collapseTextIncludingAllCausalMessages(Throwable) ;
use with care (limit once) as repeated usage can result in multiple copies of the same message |
static java.lang.String |
collapseText(java.lang.Throwable t)
like
collapse(Throwable) but returning a one-line message suitable for logging without traces |
static java.lang.String |
collapseTextIncludingAllCausalMessages(java.lang.Throwable t)
normally
collapseText(Throwable) will stop following causal chains when encountering an interesting exception
with a message; this variant will continue to follow such causal chains, showing all messages. |
static java.lang.Throwable |
create(java.util.Collection<? extends java.lang.Throwable> exceptions)
creates the given exception, but without propagating it, for use when caller will be wrapping
|
static java.lang.RuntimeException |
create(java.lang.String prefix,
java.util.Collection<? extends java.lang.Throwable> exceptions)
creates the given exception, but without propagating it, for use when caller will be wrapping
|
static java.lang.Throwable |
getFirstInteresting(java.lang.Throwable throwable)
returns the first exception in the call chain which is not of common uninteresting types
(ie excluding ExecutionException and PropagatedRuntimeExceptions);
or the original throwable if all are uninteresting
|
static <T extends java.lang.Throwable> |
getFirstThrowableOfType(java.lang.Throwable from,
java.lang.Class<T> clazz)
returns the first exception of the given type, or null
|
static boolean |
isPrefixBoring(java.lang.Throwable t)
Returns whether this is throwable either known to be boring or to have an unuseful prefix;
null is *not* boring.
|
static java.lang.RuntimeException |
propagate(java.util.Collection<? extends java.lang.Throwable> exceptions) |
static java.lang.RuntimeException |
propagate(java.lang.String prefix,
java.util.Collection<? extends java.lang.Throwable> exceptions) |
static java.lang.RuntimeException |
propagate(java.lang.Throwable throwable)
Propagate a
Throwable as a RuntimeException . |
static java.lang.RuntimeException |
propagateCollapsed(java.lang.Throwable source)
Deprecated.
since 0.7.0 same as
propagate(Throwable) |
static void |
propagateIfFatal(java.lang.Throwable throwable)
Propagate exceptions which are fatal.
|
public static boolean isPrefixBoring(java.lang.Throwable t)
public static java.lang.RuntimeException propagate(java.lang.Throwable throwable)
Throwable
as a RuntimeException
.
Like Guava Throwables.propagate(Throwable)
but:
RuntimeInterruptedException
to handle InterruptedException
s; and
public static void propagateIfFatal(java.lang.Throwable throwable)
Propagates only those exceptions which one rarely (if ever) wants to capture,
such as InterruptedException
and Error
s.
public static <T extends java.lang.Throwable> T getFirstThrowableOfType(java.lang.Throwable from, java.lang.Class<T> clazz)
public static java.lang.Throwable getFirstInteresting(java.lang.Throwable throwable)
public static java.lang.Throwable collapse(java.lang.Throwable source)
PropagatedRuntimeException
whose
message and cause are taken from the first _interesting_ element in the sourcepublic static java.lang.Throwable collapseIncludingAllCausalMessages(java.lang.Throwable source)
collapse(Throwable)
but includes causal messages in the message as per collapseTextIncludingAllCausalMessages(Throwable)
;
use with care (limit once) as repeated usage can result in multiple copies of the same messagepublic static java.lang.Throwable collapse(java.lang.Throwable source, boolean collapseCausalChain)
PropagatedRuntimeException
whose
message is taken from the first _interesting_ element in the source,
and optionally also the causal chainpublic static java.lang.RuntimeException propagateCollapsed(java.lang.Throwable source)
propagate(Throwable)
public static java.lang.String collapseText(java.lang.Throwable t)
collapse(Throwable)
but returning a one-line message suitable for logging without tracespublic static java.lang.String collapseTextIncludingAllCausalMessages(java.lang.Throwable t)
collapseText(Throwable)
will stop following causal chains when encountering an interesting exception
with a message; this variant will continue to follow such causal chains, showing all messages.
for use e.g. when verbose is desired in the single-line message.public static java.lang.RuntimeException propagate(java.util.Collection<? extends java.lang.Throwable> exceptions)
public static java.lang.RuntimeException propagate(java.lang.String prefix, java.util.Collection<? extends java.lang.Throwable> exceptions)
public static java.lang.Throwable create(java.util.Collection<? extends java.lang.Throwable> exceptions)
public static java.lang.RuntimeException create(java.lang.String prefix, java.util.Collection<? extends java.lang.Throwable> exceptions)