Class NeverThrowsException

All Implemented Interfaces:
Serializable

public final class NeverThrowsException extends RuntimeException
The NeverThrowsException class is an uninstantiable placeholder exception which should be used for indicating that a Function or AsyncFunction never throws an exception (i.e. the function cannot fail).
See Also:
  • Method Details

    • neverThrown

      public static <V, E extends Exception> Function<NeverThrowsException,V,E> neverThrown()
      Utility method returning an empty function, whose goal is to ease the transformation of a Promise type. Its main usage will be as the second argument in Promise.then(Function, Function). The implementation of this function is just to throw an IllegalStateException : but it will never be invoked as an Exception of type NeverThrowsException will never be thrown.
      Type Parameters:
      V - The expected type of that function
      E - The new Exception that can be thrown by this function.
      Returns:
      a function that will throw an IllegalStateException : but it will never be invoked as an Exception of type NeverThrowsException will never be thrown.
    • neverThrownAsync

      public static <V, E extends Exception> AsyncFunction<NeverThrowsException,V,E> neverThrownAsync()
      Utility method returning an empty function, whose goal is to ease the transformation of a Promise type. Its main usage will be as the second argument in Promise.thenAsync(AsyncFunction, AsyncFunction). The implementation of this function is just to return a promise of an IllegalStateException : but it will never be invoked as an Exception of type NeverThrowsException will never be thrown.
      Type Parameters:
      V - The expected type of that function
      E - The new Exception that can be thrown by this function.
      Returns:
      an async function that will throw an IllegalStateException : but it will never be invoked as an Exception of type NeverThrowsException will never be thrown.