java.lang.Object
is.codion.common.utilities.exceptions.Exceptions

public final class Exceptions extends Object
Exception handling utilities.
  • Method Details

    • runtime

      public static RuntimeException runtime(Throwable throwable)

      Returns the given Throwable in case it is a RuntimeException or else a RuntimeException wrapping it.

      Note that if a new wrapper RuntimeException is created, it has the stacktrace of the original throwable, as well as its message, while keeping the original throwable as its cause.

      Parameters:
      throwable - the throwable
    • runtime

      public static RuntimeException runtime(Throwable throwable, Class<? extends Throwable>... unwrap)

      Returns the given Throwable in case it is a RuntimeException or else a RuntimeException wrapping it.

      Note that if a new wrapper RuntimeException is created, it has the stacktrace of the unwrapped throwable, as well as its message, while keeping the unwrapped throwable as its cause.

      Parameters:
      throwable - the throwable
      unwrap - unwraps these exceptions
    • unwrap

      public static Throwable unwrap(Throwable throwable, Collection<Class<? extends Throwable>> unwrap)
      Unwraps the given throwable.
      Parameters:
      throwable - the exception to unwrap
      unwrap - the exception types to unwrap
      Returns:
      the unwrapped exception