java.lang.Object
io.fusionauth.http.server.ExceptionHandlerContext
Provide context to the exception handler.
- Author:
- Daniel DeGroff
-
Constructor Summary
ConstructorsConstructorDescriptionExceptionHandlerContext(Logger logger, HTTPRequest request, int statusCode, Throwable throwable) -
Method Summary
Modifier and TypeMethodDescriptionThis is provided for convenience, but you may wish to use your own logger.This may be useful if you wish to know additional context of the exception such as the URI of the current HTTP request.intvoidsetStatusCode(int statusCode) Suggest a status code for the HTTP response.
-
Constructor Details
-
ExceptionHandlerContext
public ExceptionHandlerContext(Logger logger, HTTPRequest request, int statusCode, Throwable throwable)
-
-
Method Details
-
getLogger
This is provided for convenience, but you may wish to use your own logger.- Returns:
- the optional logger to use in the exception handler.
-
getRequest
This may be useful if you wish to know additional context of the exception such as the URI of the current HTTP request.Modifications to this object will have no effect on current or futures requests.
- Returns:
- the current HTTP request, or null if this exception was taking prior to constructing the HTTP request. This is unlikely but please account for this value being null.
-
getStatusCode
public int getStatusCode()- Returns:
- the desired status code for the HTTP response.
-
setStatusCode
public void setStatusCode(int statusCode) Suggest a status code for the HTTP response. This value will be used unless the response has already been committed meaning bytes have already been written to the client and the HTTP server is not able to modify the response code.- Parameters:
statusCode- the desired status code to set on the HTTP response.
-
getThrowable
- Returns:
- the unexpected exception to handle
-