HttpException

public class HttpException extends Exception

The http exception objects are thrown by the action handler when it wishes to abort the processing when it faces an error.

Fields

message

public String message

status

public HttpResponseStatus status

Constructors

HttpException

public HttpException(HttpResponseStatus status, String message)

Initialize the Exception with appropriate status code and a message

Parameters:
  • status – Status of the response.
  • message – Message to be present in the response.

See also: HttpResponseStatus

Methods

conflict

public static HttpException conflict(String message)

Returns an Exception object that returns response with status “409 Conflict” and a custom message

forbidden

public static HttpException forbidden(String message)

Returns an Exception object that returns response with status “403 Forbidden” and a custom message

internalServerError

public static HttpException internalServerError(String message)

Returns an Exception object that returns response with status “500 Internal Server Error” and a custom message

notFound

public static HttpException notFound(String message)

Raise to return response with status “404 Not Found” and a custom message

unAuthorized

public static HttpException unAuthorized(String message)

Returns an Exception object that returns response with status “404 Not Found” and a custom message