Class ExceptionUtil

java.lang.Object
liquibase.util.ExceptionUtil

public class ExceptionUtil extends Object
  • 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 through
      desiredCause - 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

      public static boolean showExceptionInLog(Throwable exception)
    • doSilently

      public static <T> T doSilently(Callable<T> callback)
      Executes a given Callable and returns its result, swallowing any exceptions that occur. If an exception is thrown, this method returns null.
      Type Parameters:
      T - the return type of the Callable
      Parameters:
      callback - the code to execute
      Returns:
      the value returned by the callback, or null if an exception is thrown
    • doSilently

      public static <T> void doSilently(ExceptionUtil.ExceptionRunnable callback)
      Executes a given ExceptionUtil.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