Class ExceptionUtils

java.lang.Object
org.pepsoft.util.ExceptionUtils

public final class ExceptionUtils extends Object
  • Method Details

    • getUltimateCause

      public static Throwable getUltimateCause(Throwable t)
      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

      public static boolean chainContains(Throwable exception, Class<? extends Throwable> exceptionType)
      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:
      true if 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 null if there is no such exception.