public abstract class ExceptionUtils extends Object
| Modifier and Type | Method and Description |
|---|---|
static <T extends Throwable> |
findException(Throwable exception,
Class<T> exceptionClass)
Checks if the given
exception class is an instance of the given exceptionClass. |
static Optional<Throwable> |
findException(Throwable exception,
Predicate<Throwable> predicate)
Checks if the given
exception matches the given predicate. |
public static Optional<Throwable> findException(Throwable exception, Predicate<Throwable> predicate)
exception matches the given predicate. If it does an optional with the
exception is returned, if not the cause of the exception is checked and returned if matching and so on until a
match is found. If neither the given exception nor any of its causes match the predicate an empty Optional is
returned.exception - the exception to checkpredicate - the predicate to check the exception and its causespublic static <T extends Throwable> Optional<T> findException(Throwable exception, Class<T> exceptionClass)
exception class is an instance of the given exceptionClass. If so an optional with the
exception is returned. If not the cause of the exception is checked and returned if matching and so on until a
match is found. If neither the given exception nor any of its causes match the predicate an empty Optional is
returned.exception - the exception to checkexceptionClass - the target exception classCopyright © 2010–2018. All rights reserved.