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  PropagatedRuntimeExceptionwhose 
 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  PropagatedRuntimeExceptionwhose 
 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 percollapseTextIncludingAllCausalMessages(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.String | collapseTextInContext(java.lang.Throwable t,
                     java.lang.Object... contexts) | 
| 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 whose message is potentially interesting,
 in the sense that it is has some chance of giving helpful information as the cause. | 
| static java.lang.Throwable | getFirstThrowableMatching(java.lang.Throwable from,
                         returns the first exception that matches the filter, or null | 
| 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 java.lang.String | getMessageWithAppropriatePrefix(java.lang.Throwable t)Like  Throwable.toString()except suppresses boring prefixes and replaces prefixes with sensible messages where required | 
| static boolean | isPrefixBoring(java.lang.Throwable t)Returns whether the prefix is throwable either known to be boring or to have an unhelpful type name (prefix)
 which should be suppressed in messages. | 
| static boolean | isPrefixRequiredForMessageToMakeSense(java.lang.Throwable t)Some throwables require a prefix for the message to make sense,
 for instance NoClassDefFoundError's message is often just the type. | 
| static boolean | isSkippableInContext(java.lang.Throwable e,
                    java.lang.Object... contexts)True if the given exception is skippable in any of the supplied contexts. | 
| 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.String msg,
         java.lang.Throwable throwable)See  propagate(Throwable). | 
| static java.lang.RuntimeException | propagate(java.lang.Throwable throwable)Propagate a  Throwableas aRuntimeException. | 
| static java.lang.RuntimeException | propagateAnnotated(java.lang.String msg,
                  java.lang.Throwable throwable)As  propagate(String, Throwable)but always re-wraps including the given message. | 
| 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)
null is accepted but treated as not boring.
public static java.lang.RuntimeException propagate(java.lang.Throwable throwable)
Throwable as a RuntimeException.
 
 Like Guava Throwables#propagate(Throwable) but:
 
RuntimeInterruptedException to handle InterruptedExceptions; and
 public static java.lang.RuntimeException propagate(java.lang.String msg,
                                   java.lang.Throwable throwable)
propagate(Throwable).
 
 The given message is included only if the given Throwable
 needs to be wrapped; otherwise the message is not used.
 To always include the message, use propagateAnnotated(String, Throwable).
public static java.lang.RuntimeException propagateAnnotated(java.lang.String msg,
                                            java.lang.Throwable throwable)
propagate(String, Throwable) but always re-wraps including the given message.public static void propagateIfFatal(java.lang.Throwable throwable)
 Propagates only those exceptions which one rarely (if ever) wants to capture,
 such as InterruptedException and Errors.
public static <T extends java.lang.Throwable> T getFirstThrowableOfType(java.lang.Throwable from,
                                                        java.lang.Class<T> clazz)
public static java.lang.Throwable getFirstThrowableMatching(java.lang.Throwable from,
                                             filter) 
public static java.lang.Throwable getFirstInteresting(java.lang.Throwable throwable)
 more specifically this drops those which typically wrap such causes giving chain / thread info,
 reporting rather than causal explanation or important context -- 
 ie excluding ExecutionException always,
 and PropagatedRuntimeException if it has no message,
 and similar such.
 
if all are "uninteresting" in this sense (which should not normally be the case) this method just returns the original.
 often looking for a UserFacingException eg using getFirstThrowableOfType(Throwable, Class)
 is a better way to give a user-facing message.
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 boolean isSkippableInContext(java.lang.Throwable e,
                           java.lang.Object... contexts)
public 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 collapseTextInContext(java.lang.Throwable t,
                                     java.lang.Object... contexts)
public 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(@Nullable
                                java.lang.String prefix,
                                java.util.Collection<? extends java.lang.Throwable> exceptions)
public static boolean isPrefixRequiredForMessageToMakeSense(java.lang.Throwable t)
public static java.lang.String getMessageWithAppropriatePrefix(java.lang.Throwable t)
Throwable.toString() except suppresses boring prefixes and replaces prefixes with sensible messages where required