Class Exceptions

java.lang.Object
dev.derklaro.reflexion.internal.util.Exceptions

public final class Exceptions extends Object
A utility to improve working with exceptions thrown during the program runtime.
Since:
1.8.0
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    private
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static boolean
    isFatal(@NotNull Throwable throwable)
    Get if the given exception is an unrecoverable error which prevents the program to resume (on the current thread).
    static void
    rethrowIfFatal(@NotNull Throwable throwable)
    Rethrows the given exception if it signals an unrecoverable error which prevents the program to resume (on the current thread).
    static <T extends Throwable>
    void
    throwUnchecked(@NotNull Throwable throwable)
    Throws the given exception as an unchecked exception removing the need to catch non-runtime exceptions.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • Exceptions

      private Exceptions()
  • Method Details

    • throwUnchecked

      public static <T extends Throwable> void throwUnchecked(@NotNull @NotNull Throwable throwable) throws T
      Throws the given exception as an unchecked exception removing the need to catch non-runtime exceptions.
      Type Parameters:
      T - the inferred type of the throwable.
      Parameters:
      throwable - the throwable to rethrow.
      Throws:
      T - the exception to rethrow.
      NullPointerException - if the given throwable is null.
    • isFatal

      public static boolean isFatal(@NotNull @NotNull Throwable throwable)
      Get if the given exception is an unrecoverable error which prevents the program to resume (on the current thread).
      Parameters:
      throwable - the throwable to check.
      Returns:
      true if the exception is unrecoverable for the current thread, false otherwise.
      Throws:
      NullPointerException - if the given throwable is null.
    • rethrowIfFatal

      public static void rethrowIfFatal(@NotNull @NotNull Throwable throwable)
      Rethrows the given exception if it signals an unrecoverable error which prevents the program to resume (on the current thread).
      Parameters:
      throwable - the throwable to rethrow if it is fatal.
      Throws:
      NullPointerException - if the given throwable is null.