Class FindExceptionCause

java.lang.Object
io.deephaven.util.FindExceptionCause

public class FindExceptionCause extends Object
  • Constructor Details

    • FindExceptionCause

      public FindExceptionCause()
  • Method Details

    • findCause

      @SafeVarargs public static Exception findCause(Exception original, Class<? extends Exception>... expectedTypes)
      Given an exception and a list of expected exception types, traverse the cause tree and return the first exception that matches the list of expected cause types.
    • findCause

      @SafeVarargs public static Throwable findCause(Throwable original, Class<? extends Throwable>... expectedTypes)
      Given a throwable and a list of expected throwable types, traverse the cause tree and return the first exception that matches the list of expected cause types.
    • isOrCausedBy

      public static <E extends Throwable> Optional<E> isOrCausedBy(@NotNull @NotNull Throwable original, @NotNull @NotNull Class<E> expectedType)
      Given a Throwable, and an expected type, return an optional that is populated if the original was an instance of the expected type or was caused by the expected type.
      Parameters:
      original - The original throwable
      expectedType - The expected type to find
      Returns:
      A completed Optional containing the found cause, or an empty Optional
    • shortCauses

      public static String shortCauses(@NotNull @NotNull Throwable throwable, String lineSeparator)
      Given an exception, provide a short description of the causes. We take each cause and return a String separated by line separator and "caused by".
      Parameters:
      throwable - the Throwable to get causes from
      lineSeparator - a separation string (e.g., newline or <br>)
      Returns:
      the causes formatted one per line
    • findLastCause

      @SafeVarargs public static Throwable findLastCause(Throwable original, Class<? extends Throwable>... expectedTypes)
      Given a throwable and a list of expected throwable types, traverse the cause tree and return the last exception that matches the list of expected cause types.
      Parameters:
      original - the original Throwable
      expectedTypes - the list of expected types
      Returns:
      the last Throwable of one of the defined types, or the original Throwable if none were found