Class ExceptionUtils

java.lang.Object
io.github.amanzat.util.ExceptionUtils

public final class ExceptionUtils extends Object
Miscellaneous Throwable utility methods and constants.
  • Constructor Details

    • ExceptionUtils

      public ExceptionUtils()
  • Method Details

    • throwableOfType

      public static <T extends Throwable> T throwableOfType(Throwable throwable, Class<T> type)
      Returns the first throwable of the specified type in the exception chain if exists, null otherwise.
      Type Parameters:
      T - The searched throwable type
      Parameters:
      throwable - The Throwable to inspect
      type - The type to search for
      Returns:
      The first throwable of the specified type in the exception chain if exists, null otherwise.
    • getCause

      public static Throwable getCause(Throwable throwable)
      Returns the cause of this throwable if exists and is not the same instance with the throwable.
      Parameters:
      throwable - The throwable
      Returns:
      The cause of this throwable.