Class HawaiiSpringResponseEntityExceptionHandler
java.lang.Object
org.springframework.web.servlet.mvc.method.annotation.ResponseEntityExceptionHandler
org.hawaiiframework.web.exception.HawaiiSpringResponseEntityExceptionHandler
- All Implemented Interfaces:
org.springframework.beans.factory.Aware
,org.springframework.context.MessageSourceAware
@Order(0)
@ControllerAdvice
public class HawaiiSpringResponseEntityExceptionHandler
extends org.springframework.web.servlet.mvc.method.annotation.ResponseEntityExceptionHandler
This class creates proper HTTP response bodies for exceptions.
Separate controller advice with it's own order, so that is used before the HawaiiResponseEntityExceptionHandler
. This is needed because in the code we tend to wrap
exceptions within Hawaii exceptions and the Hawaii exception is preferred above the cause within
that exceptions.
(in other words, don't delete this file or merge this file with the HawaiiResponseEntityExceptionHandler
!)
- Since:
- 6.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
ConstructorDescriptionHawaiiSpringResponseEntityExceptionHandler
(ErrorResponseEntityBuilder errorResponseEntityBuilder) Constructor with anerrorResponseEntityBuilder
. -
Method Summary
Modifier and TypeMethodDescriptionorg.springframework.http.ResponseEntity<Object>
accessDeniedException
(org.springframework.security.access.AccessDeniedException exception, org.springframework.web.context.request.WebRequest request) HandlesAccessDeniedException
instances.protected org.springframework.http.ResponseEntity<Object>
handleHttpMessageNotReadable
(org.springframework.http.converter.HttpMessageNotReadableException exception, org.springframework.http.HttpHeaders headers, org.springframework.http.HttpStatusCode statusCode, org.springframework.web.context.request.WebRequest request) The overridden message not readable exception handler.Methods inherited from class org.springframework.web.servlet.mvc.method.annotation.ResponseEntityExceptionHandler
createProblemDetail, createResponseEntity, getMessageSource, handleAsyncRequestTimeoutException, handleBindException, handleConversionNotSupported, handleErrorResponseException, handleException, handleExceptionInternal, handleHandlerMethodValidationException, handleHttpMediaTypeNotAcceptable, handleHttpMediaTypeNotSupported, handleHttpMessageNotWritable, handleHttpRequestMethodNotSupported, handleMaxUploadSizeExceededException, handleMethodArgumentNotValid, handleMethodValidationException, handleMissingPathVariable, handleMissingServletRequestParameter, handleMissingServletRequestPart, handleNoHandlerFoundException, handleNoResourceFoundException, handleServletRequestBindingException, handleTypeMismatch, setMessageSource
-
Constructor Details
-
HawaiiSpringResponseEntityExceptionHandler
public HawaiiSpringResponseEntityExceptionHandler(ErrorResponseEntityBuilder errorResponseEntityBuilder) Constructor with anerrorResponseEntityBuilder
.
-
-
Method Details
-
accessDeniedException
@ExceptionHandler(org.springframework.security.access.AccessDeniedException.class) @ResponseBody public org.springframework.http.ResponseEntity<Object> accessDeniedException(org.springframework.security.access.AccessDeniedException exception, org.springframework.web.context.request.WebRequest request) HandlesAccessDeniedException
instances.The response status is: 403 Forbidden.
- Parameters:
exception
- the exceptionrequest
- the current request- Returns:
- a response entity reflecting the current exception
-
handleHttpMessageNotReadable
protected org.springframework.http.ResponseEntity<Object> handleHttpMessageNotReadable(org.springframework.http.converter.HttpMessageNotReadableException exception, org.springframework.http.HttpHeaders headers, org.springframework.http.HttpStatusCode statusCode, org.springframework.web.context.request.WebRequest request) The overridden message not readable exception handler.- Overrides:
handleHttpMessageNotReadable
in classorg.springframework.web.servlet.mvc.method.annotation.ResponseEntityExceptionHandler
- Parameters:
exception
- the exception to handleheaders
- the headers to use for the responsestatusCode
- the status code to use for the responserequest
- the current request- Returns:
- a response entity reflecting the current exception
-