Class Throwables

java.lang.Object
com.palantir.ptoss.util.Throwables

public final class Throwables extends Object
A class of utility methods to make exception handling cleaner.
  • Method Details

    • throwUncheckedException

      public static RuntimeException throwUncheckedException(Throwable ex)
      If Throwable is a RuntimeException or Error, rethrow it. If not, throw a new PalantirRuntimeException(ex)
    • throwIfInstance

      public static <K extends Throwable> void throwIfInstance(Throwable t, Class<K> clazz) throws K
      if (t instanceof K) throw (K)t;

      Note: The runtime type of the thrown exception will be the same as t even if clazz is a supertype of t.

      Throws:
      K extends Throwable