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. |
static boolean |
isExplicitlyNonTransient(Throwable failure)
Indicates whether the given
failure is clearly non-transient. |
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 classpublic static boolean isExplicitlyNonTransient(Throwable failure)
failure is clearly non-transient. Non-transient exceptions indicate
that the handling of the message will fail in the same way if retriedfailure - the exception that occurred while processing a messagetrue if the exception is clearly non-transientCopyright © 2010–2023. All rights reserved.