java.lang.Object
java.lang.Throwable
java.lang.Exception
java.lang.RuntimeException
io.helidon.http.HttpException
- All Implemented Interfaces:
Serializable
- Direct Known Subclasses:
BadRequestException
,ForbiddenException
,InternalServerException
,NotFoundException
,UnauthorizedException
Runtime exception for applications.
This exception may be thrown during request processing if a specific HTTP error response needs to be produced. Only effective if thrown before the status code is sent.
- See Also:
-
Constructor Summary
ConstructorDescriptionHttpException
(String message) CreatesHttpException
associated withStatus.INTERNAL_SERVER_ERROR_500
.HttpException
(String message, Status status) CreatesHttpException
.HttpException
(String message, Status status, boolean keepAlive) CreatesHttpException
.HttpException
(String message, Status status, Throwable cause) CreatesHttpException
.HttpException
(String message, Status status, Throwable cause, boolean keepAlive) CreatesHttpException
.HttpException
(String message, Throwable cause) CreatesHttpException
associated withStatus.INTERNAL_SERVER_ERROR_500
. -
Method Summary
Modifier and TypeMethodDescriptionSet a response header that should be used if this exception is not handled.headers()
Headers as currently configured in this exception.boolean
Whether we should attempt to keep the connection alive (if enabled for it).final Status
status()
Obtain the associated http status.Methods inherited from class java.lang.Throwable
addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
-
Constructor Details
-
HttpException
CreatesHttpException
associated withStatus.INTERNAL_SERVER_ERROR_500
.- Parameters:
message
- the message
-
HttpException
CreatesHttpException
associated withStatus.INTERNAL_SERVER_ERROR_500
.- Parameters:
message
- the messagecause
- the cause of this exception
-
HttpException
CreatesHttpException
.- Parameters:
message
- the messagestatus
- the http status
-
HttpException
CreatesHttpException
.- Parameters:
message
- the messagestatus
- the http statuskeepAlive
- whether to keep the connection alive
-
HttpException
CreatesHttpException
.- Parameters:
message
- the messagestatus
- the http statuscause
- the cause of this exception
-
HttpException
CreatesHttpException
.- Parameters:
message
- the messagestatus
- the http statuscause
- the cause of this exceptionkeepAlive
- whether to keep this connection alive
-
-
Method Details
-
status
Obtain the associated http status.- Returns:
- the http status
-
keepAlive
public boolean keepAlive()Whether we should attempt to keep the connection alive (if enabled for it). Some exceptions may allow the connection to be further used (such asNotFoundException
.- Returns:
- whether to keep alive
-
header
Set a response header that should be used if this exception is not handled.- Parameters:
header
- header to set- Returns:
- updated instance
-
headers
Headers as currently configured in this exception.- Returns:
- headers configured for this exception
-