@ControllerAdvice
public class HawaiiResponseEntityExceptionHandler
extends org.springframework.web.servlet.mvc.method.annotation.ResponseEntityExceptionHandler
implements org.springframework.beans.factory.InitializingBean
| Constructor and Description |
|---|
HawaiiResponseEntityExceptionHandler(ValidationErrorResourceAssembler validationErrorResourceAssembler,
ExceptionResponseFactory exceptionResponseFactory) |
| Modifier and Type | Method and Description |
|---|---|
protected void |
addResponseEnricher(ErrorResponseEnricher errorResponseEnricher)
Registers a
ErrorResponseEnricher. |
void |
afterPropertiesSet() |
protected ErrorResponseResource |
buildErrorResponseBody(java.lang.Throwable throwable,
org.springframework.http.HttpStatus status,
org.springframework.web.context.request.WebRequest request)
Builds a meaningful response body for the given throwable, HTTP status and request.
|
protected void |
configureResponseEnrichers()
Configures the error response enrichers.
|
protected java.util.Collection<ErrorResponseEnricher> |
getResponseEnrichers()
Returns a collection of registered response enrichers.
|
org.springframework.http.ResponseEntity |
handleApiException(ApiException e,
org.springframework.web.context.request.WebRequest request)
Handles
ValidationException instances. |
protected org.springframework.http.ResponseEntity<java.lang.Object> |
handleExceptionInternal(java.lang.Exception ex,
java.lang.Object body,
org.springframework.http.HttpHeaders headers,
org.springframework.http.HttpStatus status,
org.springframework.web.context.request.WebRequest request) |
org.springframework.http.ResponseEntity |
handleHttpException(HttpException e,
org.springframework.web.context.request.WebRequest request)
Handles
HttpException instances. |
org.springframework.http.ResponseEntity |
handleThrowable(java.lang.Throwable t,
org.springframework.web.context.request.WebRequest request)
Handles
Throwable instances. |
org.springframework.http.ResponseEntity |
handleValidationException(ValidationException e,
org.springframework.web.context.request.WebRequest request)
Handles
ValidationException instances. |
protected void |
removeResponseEnricher(java.lang.Class<? extends ErrorResponseEnricher> className)
De-registers a
ErrorResponseEnricher based on its class name. |
protected void |
removeResponseEnricher(ErrorResponseEnricher errorResponseEnricher)
De-registers a
ErrorResponseEnricher. |
handleAsyncRequestTimeoutException, handleBindException, handleConversionNotSupported, handleException, handleHttpMediaTypeNotAcceptable, handleHttpMediaTypeNotSupported, handleHttpMessageNotReadable, handleHttpMessageNotWritable, handleHttpRequestMethodNotSupported, handleMethodArgumentNotValid, handleMissingPathVariable, handleMissingServletRequestParameter, handleMissingServletRequestPart, handleNoHandlerFoundException, handleNoSuchRequestHandlingMethod, handleServletRequestBindingException, handleTypeMismatchpublic HawaiiResponseEntityExceptionHandler(ValidationErrorResourceAssembler validationErrorResourceAssembler, ExceptionResponseFactory exceptionResponseFactory)
public void afterPropertiesSet()
throws java.lang.Exception
afterPropertiesSet in interface org.springframework.beans.factory.InitializingBeanjava.lang.Exception@ExceptionHandler(value=HttpException.class) @ResponseBody public org.springframework.http.ResponseEntity handleHttpException(HttpException e, org.springframework.web.context.request.WebRequest request)
HttpException instances.
Each HttpException has an associated HttpStatus that is used as the response status.
e - the exceptionrequest - the current request@ExceptionHandler(value=ValidationException.class) @ResponseBody public org.springframework.http.ResponseEntity handleValidationException(ValidationException e, org.springframework.web.context.request.WebRequest request)
ValidationException instances.
The response status is: 400 Bad Request.
e - the exceptionrequest - the current request@ExceptionHandler(value=ApiException.class) @ResponseBody public org.springframework.http.ResponseEntity handleApiException(ApiException e, org.springframework.web.context.request.WebRequest request)
ValidationException instances.
The response status is: 400 Bad Request.
e - the exceptionrequest - the current request@ExceptionHandler(value=java.lang.Throwable.class)
@ResponseBody
public org.springframework.http.ResponseEntity handleThrowable(java.lang.Throwable t,
org.springframework.web.context.request.WebRequest request)
Throwable instances. This method acts as a fallback handler.t - the exceptionrequest - the current requestprotected org.springframework.http.ResponseEntity<java.lang.Object> handleExceptionInternal(java.lang.Exception ex,
java.lang.Object body,
org.springframework.http.HttpHeaders headers,
org.springframework.http.HttpStatus status,
org.springframework.web.context.request.WebRequest request)
handleExceptionInternal in class org.springframework.web.servlet.mvc.method.annotation.ResponseEntityExceptionHandlerprotected ErrorResponseResource buildErrorResponseBody(java.lang.Throwable throwable, org.springframework.http.HttpStatus status, org.springframework.web.context.request.WebRequest request)
ErrorResponseResource using exceptionResponseFactory and then applies
the error response enrichers returned from getResponseEnrichers() to complete the response.throwable - the exceptionstatus - the HTTP statusrequest - the current requestprotected void addResponseEnricher(ErrorResponseEnricher errorResponseEnricher)
ErrorResponseEnricher.errorResponseEnricher - the error response enricherprotected void removeResponseEnricher(ErrorResponseEnricher errorResponseEnricher)
ErrorResponseEnricher.errorResponseEnricher - the error response enricherprotected void removeResponseEnricher(java.lang.Class<? extends ErrorResponseEnricher> className)
ErrorResponseEnricher based on its class name.className - the class name of the ErrorResponseEnricher to removeprotected void configureResponseEnrichers()
Subclasses may override this method to remove existing or add additional listeners,
using addResponseEnricher(ErrorResponseEnricher) and removeResponseEnricher(ErrorResponseEnricher).
The default implementation adds the following listeners:
protected java.util.Collection<ErrorResponseEnricher> getResponseEnrichers()