Class Exceptions


  • public final class Exceptions
    extends java.lang.Object
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static <T extends java.lang.Throwable>
      java.lang.RuntimeException
      rethrowChecked​(java.lang.Exception e)
      Rethrow a checked exception without wrapping into an unchecked exception, bypassing the Java compiler's checks.
      • Methods inherited from class java.lang.Object

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

      • rethrowChecked

        public static <T extends java.lang.Throwable> java.lang.RuntimeException rethrowChecked​(java.lang.Exception e)
                                                                                         throws T extends java.lang.Throwable
        Rethrow a checked exception without wrapping into an unchecked exception, bypassing the Java compiler's checks. This method is particularly useful in lambdas, which are defined not throwing any checked exceptions, e. g. Map.compute(Object, BiFunction). This method will never return anything, it will just throw the exception that was passed to it as an argument. This method is defined to return RuntimeException to allow the following code: ... catch (IOException e) { throw Exceptions.rethrowChecked(e); }
        Throws:
        T extends java.lang.Throwable