Class Throwables


  • public final class Throwables
    extends java.lang.Object
    Miscellaneous functions dealing with Throwable.
    Since:
    4.12
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      private Throwables()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      private static <T extends java.lang.Throwable>
      void
      rethrow​(java.lang.Throwable e)  
      static java.lang.Exception rethrowAsException​(java.lang.Throwable e)
      Rethrows the given Throwable, allowing the caller to declare that it throws Exception.
      • Methods inherited from class java.lang.Object

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

      • Throwables

        private Throwables()
    • Method Detail

      • rethrowAsException

        public static java.lang.Exception rethrowAsException​(java.lang.Throwable e)
                                                      throws java.lang.Exception
        Rethrows the given Throwable, allowing the caller to declare that it throws Exception. This is useful when your callers have nothing reasonable they can do when a Throwable is thrown. This is declared to return Exception so it can be used in a throw clause:
         try {
           doSomething();
         } catch (Throwable e} {
           throw Throwables.rethrowAsException(e);
         }
         doSomethingLater();
         
        Parameters:
        e - exception to rethrow
        Returns:
        does not return anything
        Throws:
        java.lang.Exception
        Since:
        4.12
      • rethrow

        private static <T extends java.lang.Throwable> void rethrow​(java.lang.Throwable e)
                                                             throws T extends java.lang.Throwable
        Throws:
        T extends java.lang.Throwable