Package org.pepsoft.util
Class ExceptionUtils
java.lang.Object
org.pepsoft.util.ExceptionUtils
-
Method Summary
Modifier and TypeMethodDescriptionstatic booleanchainContains(Throwable exception, Class<? extends Throwable> exceptionType) Determine whether a particular exception type occurs on the chain of causes of an exception.static <T extends Throwable>
TgetFromChainOfType(Throwable exception, Class<T> exceptionType) Get the first exception that has a particular type fromt he chain of causes of an exception.static ThrowableGet the ultimate root cause of an exception.
-
Method Details
-
getUltimateCause
Get the ultimate root cause of an exception.- Parameters:
t- The exception of which to obtain the ultimate root cause.- Returns:
- The ultimate root cause of the specified exception.
-
chainContains
Determine whether a particular exception type occurs on the chain of causes of an exception.- Parameters:
exception- The exception of which to inspect the chain of causes.exceptionType- The type of exception for which to look.- Returns:
trueif the chain of causes of the specified exception contains an exception that has the specified type.
-
getFromChainOfType
public static <T extends Throwable> T getFromChainOfType(Throwable exception, Class<T> exceptionType) Get the first exception that has a particular type fromt he chain of causes of an exception.- Type Parameters:
T- The type of exception for which to look.- Parameters:
exception- The exception of which to inspect the chain of causes.exceptionType- The type of exception for which to look.- Returns:
- The first exception on the chain of causes of the specified exception which has the specified type, or
nullif there is no such exception.
-