Package org.axonframework.common
Class ExceptionUtils
java.lang.Object
org.axonframework.common.ExceptionUtils
Exception utility methods.
- Author:
- Rene de Waele
-
Method Summary
Modifier and TypeMethodDescriptionfindException(Throwable exception, Class<T> exceptionClass) Checks if the givenexceptionclass is an instance of the givenexceptionClass.findException(Throwable exception, Predicate<Throwable> predicate) Checks if the givenexceptionmatches the givenpredicate.static booleanisExplicitlyNonTransient(Throwable failure) Indicates whether the givenfailureis clearly non-transient.
-
Method Details
-
findException
public static Optional<Throwable> findException(Throwable exception, Predicate<Throwable> predicate) Checks if the givenexceptionmatches the givenpredicate. 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.- Parameters:
exception- the exception to checkpredicate- the predicate to check the exception and its causes- Returns:
- an optional containing the exception matching the predicate or an empty optional if neither the given exception nor any of its causes match the predicate
-
findException
public static <T extends Throwable> Optional<T> findException(Throwable exception, Class<T> exceptionClass) Checks if the givenexceptionclass is an instance of the givenexceptionClass. 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.- Parameters:
exception- the exception to checkexceptionClass- the target exception class- Returns:
- an optional containing the exception matching the predicate or an empty optional if neither the given exception nor any of its causes match the predicate
-
isExplicitlyNonTransient
Indicates whether the givenfailureis clearly non-transient. Non-transient exceptions indicate that the handling of the message will fail in the same way if retried- Parameters:
failure- the exception that occurred while processing a message- Returns:
trueif the exception is clearly non-transient
-