Class Throwables


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

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static <K extends java.lang.Throwable>
      void
      throwIfInstance​(java.lang.Throwable t, java.lang.Class<K> clazz)
      if (t instanceof K) throw (K)t;
      static java.lang.RuntimeException throwUncheckedException​(java.lang.Throwable ex)
      If Throwable is a RuntimeException or Error, rethrow it.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • throwUncheckedException

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

        public static <K extends java.lang.Throwable> void throwIfInstance​(java.lang.Throwable t,
                                                                           java.lang.Class<K> clazz)
                                                                    throws K extends java.lang.Throwable
        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 java.lang.Throwable