Package liquibase.util
Class ExceptionUtil
java.lang.Object
liquibase.util.ExceptionUtil
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic interface
Functional interface for code blocks that may throw anException
. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic <T> T
doSilently
(Callable<T> callback) Executes a givenCallable
and returns its result, swallowing any exceptions that occur.static <T> void
doSilently
(ExceptionUtil.ExceptionRunnable callback) Executes a givenExceptionUtil.ExceptionRunnable
, swallowing any exceptions that occur.static Throwable
findExceptionInCauseChain
(Throwable exceptionToSearchIn, Class<?> desiredCause) Find an exception in the stack of exception causes whose cause matches the desired one.static boolean
showExceptionInLog
(Throwable exception)
-
Constructor Details
-
ExceptionUtil
public ExceptionUtil()
-
-
Method Details
-
findExceptionInCauseChain
public static Throwable findExceptionInCauseChain(Throwable exceptionToSearchIn, Class<?> desiredCause) Find an exception in the stack of exception causes whose cause matches the desired one. Note that the exception whose cause matches the desired cause is returned, NOT the cause itself.- Parameters:
exceptionToSearchIn
- the exception to search throughdesiredCause
- the cause that should be found in the stack of causes in the exception to search in- Returns:
- the desired exception, if found, or null otherwise
-
showExceptionInLog
-
doSilently
Executes a givenCallable
and returns its result, swallowing any exceptions that occur. If an exception is thrown, this method returnsnull
.- Type Parameters:
T
- the return type of theCallable
- Parameters:
callback
- the code to execute- Returns:
- the value returned by the callback, or
null
if an exception is thrown
-
doSilently
Executes a givenExceptionUtil.ExceptionRunnable
, swallowing any exceptions that occur. This method does not return a value.- Type Parameters:
T
- the return type, if needed (otherwise it can be omitted)- Parameters:
callback
- the code to execute
-