Class SeeqExceptions

java.lang.Object
com.seeq.utilities.exception.SeeqExceptions

public class SeeqExceptions extends Object
  • Constructor Details

    • SeeqExceptions

      public SeeqExceptions()
  • Method Details

    • getCauses

      public Stream<? extends Throwable> getCauses(Throwable throwable)
      Get the chain of Throwable causes, including the initial Throwable.
      Parameters:
      throwable - the root Throwable whose causes to follow
      Returns:
      The ordered stream of Throwables via getCause, where the first element is the first argument
    • getCause

      public <T extends Throwable> Optional<T> getCause(Throwable throwable, Class<T> causeToCheck)
      Get the first Throwable matching the given class in the cause chain beginning with the provided Throwable
      Type Parameters:
      T - the type of the cause to check for
      Parameters:
      throwable - the throwable where the causes will be inspected
      causeToCheck - the cause to check for
      Returns:
      The first matching cause is in the cause chain of throwable, otherwise empty.
    • hasCause

      public <T extends Throwable> boolean hasCause(Throwable throwable, Class<T> causeToCheck)
      Check the chain of Throwable causes to see if the expected cause is someone in the "cause chain"
      Type Parameters:
      T - the type of the cause to check for
      Parameters:
      throwable - the throwable where the causes will be inspected
      causeToCheck - the cause to check for
      Returns:
      true if cause is in the cause chain of throwable
    • isCausedByInterruption

      public static boolean isCausedByInterruption(Throwable throwable)
      Check the chain of Throwable causes to see if the cause contains an InterruptedException or OperationCanceledException
      Parameters:
      throwable - the throwable where the causes will be inspected
      Returns:
      true if the chain of throwable contains an InterruptedException or OperationCanceledException