Class HawaiiResponseEntityExceptionHandler
java.lang.Object
org.springframework.web.servlet.mvc.method.annotation.ResponseEntityExceptionHandler
org.hawaiiframework.web.exception.HawaiiResponseEntityExceptionHandler
- All Implemented Interfaces:
org.springframework.beans.factory.Aware
,org.springframework.context.MessageSourceAware
@Order
@ControllerAdvice
public class HawaiiResponseEntityExceptionHandler
extends org.springframework.web.servlet.mvc.method.annotation.ResponseEntityExceptionHandler
This class creates proper HTTP response bodies for exceptions.
- Since:
- 2.0.0
-
Field Summary
Fields inherited from class org.springframework.web.servlet.mvc.method.annotation.ResponseEntityExceptionHandler
logger, PAGE_NOT_FOUND_LOG_CATEGORY, pageNotFoundLogger
-
Constructor Summary
ConstructorDescriptionHawaiiResponseEntityExceptionHandler
(ErrorResponseEntityBuilder errorResponseEntityBuilder) The constructor with aerrorResponseEntityBuilder
. -
Method Summary
Modifier and TypeMethodDescriptionorg.springframework.http.ResponseEntity<Object>
handleApiException
(ApiException exception, org.springframework.web.context.request.WebRequest request) HandlesValidationException
instances.org.springframework.http.ResponseEntity<Object>
handleHttpException
(HttpException exception, org.springframework.web.context.request.WebRequest request) HandlesHttpException
instances.protected org.springframework.http.ResponseEntity<Object>
handleMethodArgumentNotValid
(org.springframework.web.bind.MethodArgumentNotValidException exception, org.springframework.http.HttpHeaders headers, org.springframework.http.HttpStatusCode status, org.springframework.web.context.request.WebRequest request) HandlesMethodArgumentNotValidException
instances.org.springframework.http.ResponseEntity<Object>
handleThrowable
(Throwable throwable, org.springframework.web.context.request.WebRequest request) HandlesThrowable
instances.org.springframework.http.ResponseEntity<Object>
handleValidationException
(ValidationException exception, org.springframework.web.context.request.WebRequest request) HandlesValidationException
instances.Methods inherited from class org.springframework.web.servlet.mvc.method.annotation.ResponseEntityExceptionHandler
createProblemDetail, createResponseEntity, getMessageSource, handleAsyncRequestTimeoutException, handleBindException, handleConversionNotSupported, handleErrorResponseException, handleException, handleExceptionInternal, handleHandlerMethodValidationException, handleHttpMediaTypeNotAcceptable, handleHttpMediaTypeNotSupported, handleHttpMessageNotReadable, handleHttpMessageNotWritable, handleHttpRequestMethodNotSupported, handleMaxUploadSizeExceededException, handleMethodValidationException, handleMissingPathVariable, handleMissingServletRequestParameter, handleMissingServletRequestPart, handleNoHandlerFoundException, handleNoResourceFoundException, handleServletRequestBindingException, handleTypeMismatch, setMessageSource
-
Constructor Details
-
HawaiiResponseEntityExceptionHandler
The constructor with aerrorResponseEntityBuilder
.
-
-
Method Details
-
handleHttpException
@ExceptionHandler(HttpException.class) @ResponseBody public org.springframework.http.ResponseEntity<Object> handleHttpException(HttpException exception, org.springframework.web.context.request.WebRequest request) HandlesHttpException
instances.Each
HttpException
has an associatedHttpStatus
that is used as the response status.- Parameters:
exception
- the exceptionrequest
- the current request- Returns:
- a response entity reflecting the current exception
-
handleMethodArgumentNotValid
protected org.springframework.http.ResponseEntity<Object> handleMethodArgumentNotValid(@NonNull org.springframework.web.bind.MethodArgumentNotValidException exception, @NonNull org.springframework.http.HttpHeaders headers, @NonNull org.springframework.http.HttpStatusCode status, @NonNull org.springframework.web.context.request.WebRequest request) HandlesMethodArgumentNotValidException
instances.The response status is: 400 Bad Request.
- Overrides:
handleMethodArgumentNotValid
in classorg.springframework.web.servlet.mvc.method.annotation.ResponseEntityExceptionHandler
- Parameters:
exception
- the exceptionrequest
- the current request- Returns:
- a response entity reflecting the current exception
-
handleValidationException
@ExceptionHandler(ValidationException.class) @ResponseBody public org.springframework.http.ResponseEntity<Object> handleValidationException(ValidationException exception, org.springframework.web.context.request.WebRequest request) HandlesValidationException
instances.The response status is: 400 Bad Request.
- Parameters:
exception
- the exceptionrequest
- the current request- Returns:
- a response entity reflecting the current exception
-
handleApiException
@ExceptionHandler(ApiException.class) @ResponseBody public org.springframework.http.ResponseEntity<Object> handleApiException(ApiException exception, org.springframework.web.context.request.WebRequest request) HandlesValidationException
instances.The response status is: 400 Bad Request.
- Parameters:
exception
- the exceptionrequest
- the current request- Returns:
- a response entity reflecting the current exception
-
handleThrowable
@ExceptionHandler(java.lang.Throwable.class) @ResponseBody public org.springframework.http.ResponseEntity<Object> handleThrowable(Throwable throwable, org.springframework.web.context.request.WebRequest request) HandlesThrowable
instances. This method acts as a fallback handler.- Parameters:
throwable
- the exceptionrequest
- the current request- Returns:
- a response entity reflecting the current exception
-