Class Responses


  • public final class Responses
    extends Object
    Provide out-of-the-box, pre-configured Response objects.
    • Method Detail

      • newInternalServerError

        public static Response newInternalServerError()
        Generates an empty Internal Server Error response (500).
        Returns:
        an empty Internal Server Error response (500).
      • newInternalServerError

        public static Response newInternalServerError​(Exception exception)
        Generates an Internal Server Error response (500) containing the cause of the error response.
        Parameters:
        exception - wrapped exception
        Returns:
        an empty Internal Server Error response 500 with the cause set.
      • newNotFound

        public static Response newNotFound()
        Generates an empty Not Found response (404).
        Returns:
        an empty Not Found response (404).
      • newForbidden

        public static Response newForbidden()
        Generates an empty Forbidden response (403).
        Returns:
        an empty Forbidden response (403).
      • noopExceptionFunction

        public static <V,​E extends ExceptionFunction<NeverThrowsException,​V,​E> noopExceptionFunction()
        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 return null : as its name suggests it, 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 return null and not throw any Exception.