public final class Throwables extends Object
| Modifier and Type | Method and Description |
|---|---|
static Optional<Throwable> |
findThrowableInChain(Predicate<Throwable> condition,
Throwable t)
Search an exception chain for an exception matching a given condition.
|
static Throwable |
getRootCause(Throwable throwable)
Deprecated.
consider using Apache commons-lang3 ExceptionUtils instead
|
@Deprecated public static Throwable getRootCause(Throwable throwable)
throwable. The first throwable in a chain provides
context from when the error or exception was initially detected. Example usage:
assertEquals("Unable to assign a customer id", Throwables.getRootCause(e).getMessage());
IllegalArgumentException - if there is a loop in the causal chainpublic static Optional<Throwable> findThrowableInChain(Predicate<Throwable> condition, @Nullable Throwable t)
condition - The condition to match ont - The head of the exception chainOptional containing the first match in the chain, starting from the head, or empty if no
matching exception was foundCopyright © 2011. All rights reserved.