- All Implemented Interfaces:
Serializable
- Direct Known Subclasses:
BadRequestException
,ForbiddenException
,InternalServerErrorException
,MethodNotAllowedException
,NotAcceptableException
,NotFoundException
,ServiceUnavailableException
,UnauthorizedException
,UnsupportedMediaTypeException
,WebSocketException
Base exception class used to report HTTP errors.
- Since:
- 1.0
- Author:
- Jeremy Kuhn
- See Also:
-
Constructor Summary
ConstructorDescriptionCreates an HTTP exception with default statusInternal Server Error (500)
.HttpException
(int statusCode) Creates an HTTP exception with specified HTTP status code.HttpException
(int statusCode, String message) Creates an HTTP exception with specified HTTP status code and message.HttpException
(int statusCode, String message, Throwable cause) Creates an HTTP exception with specified HTTP status code, message and cause.HttpException
(int statusCode, Throwable cause) Creates an HTTP exception with specified HTTP status code and cause.HttpException
(Status status) Creates an HTTP exception with specified HTTP status.HttpException
(Status status, String message) Creates an HTTP exception with specified HTTP status and message.HttpException
(Status status, String message, Throwable cause) Creates an HTTP exception with specified HTTP status, message and cause.HttpException
(Status status, Throwable cause) Creates an HTTP exception with specified HTTP status and cause.HttpException
(String message) Creates an HTTP exception with default statusInternal Server Error (500)
and specified message.HttpException
(String message, Throwable cause) Creates an HTTP exception with default statusInternal Server Error (500)
, specified message and causeHttpException
(Throwable cause) Creates an HTTP exception with default statusInternal Server Error (500)
and specified cause. -
Method Summary
Modifier and TypeMethodDescriptionReturns the HTTP status.Returns the HTTP status category.int
Returns the HTTP status code.Returns the HTTP status reason phrase.static HttpException
Wraps the specified error into an HttpException.Methods inherited from class java.lang.Throwable
addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
-
Constructor Details
-
HttpException
public HttpException()Creates an HTTP exception with default status
Internal Server Error (500)
. -
HttpException
Creates an HTTP exception with default status
Internal Server Error (500)
and specified message.- Parameters:
message
- a message
-
HttpException
Creates an HTTP exception with default status
Internal Server Error (500)
and specified cause.- Parameters:
cause
- a cause
-
HttpException
Creates an HTTP exception with default status
Internal Server Error (500)
, specified message and cause- Parameters:
message
- a messagecause
- a cause
-
HttpException
Creates an HTTP exception with specified HTTP status code.
- Parameters:
statusCode
- an HTTP status code- Throws:
IllegalArgumentException
- if the specified status code is invalid
-
HttpException
Creates an HTTP exception with specified HTTP status code and message.
- Parameters:
statusCode
- an HTTP status codemessage
- a message- Throws:
IllegalArgumentException
- if the specified status code is invalid
-
HttpException
Creates an HTTP exception with specified HTTP status code and cause.
- Parameters:
statusCode
- an HTTP status codecause
- a cause- Throws:
IllegalArgumentException
- if the specified status code is invalid
-
HttpException
public HttpException(int statusCode, String message, Throwable cause) throws IllegalArgumentException Creates an HTTP exception with specified HTTP status code, message and cause.
- Parameters:
statusCode
- an HTTP status codemessage
- a messagecause
- a cause- Throws:
IllegalArgumentException
- if the specified status code is invalid
-
HttpException
Creates an HTTP exception with specified HTTP status.
- Parameters:
status
- an HTTP status
-
HttpException
Creates an HTTP exception with specified HTTP status and message.
- Parameters:
status
- an HTTP statusmessage
- a message
-
HttpException
Creates an HTTP exception with specified HTTP status and cause.
- Parameters:
status
- an HTTP statuscause
- a cause
-
HttpException
Creates an HTTP exception with specified HTTP status, message and cause.
- Parameters:
status
- an HTTP statusmessage
- a messagecause
- a cause
-
-
Method Details
-
getStatus
Returns the HTTP status.
- Returns:
- an HTTP status or null if the code specified does correspond to any known status
-
getStatusCode
public int getStatusCode()Returns the HTTP status code.
- Returns:
- an HTTP status code
-
getStatusReasonPhrase
Returns the HTTP status reason phrase.
- Returns:
- a reason phrase
-
getStatusCategory
Returns the HTTP status category.
- Returns:
- an HTTP status category
-
wrap
Wraps the specified error into an HttpException.
The specified error is returned untouched if it is already an HttpException instance, ohterwise it is wrapped in an
InternalServerErrorException
.- Parameters:
error
- the error to wrap- Returns:
- the specified error if it is an HttpException, an HttpException wrapping the specified error otherwise
-