@ControllerAdvice public class HawaiiResponseEntityExceptionHandler extends ResponseEntityExceptionHandler implements InitializingBean
PAGE_NOT_FOUND_LOG_CATEGORY, pageNotFoundLogger
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(Throwable throwable,
HttpStatus status,
WebRequest request)
Builds a meaningful response body for the given throwable, HTTP status and request.
|
protected void |
configureResponseEnrichers()
Configures the error response enrichers.
|
protected Collection<ErrorResponseEnricher> |
getResponseEnrichers()
Returns a collection of registered response enrichers.
|
ResponseEntity |
handleApiException(ApiException e,
WebRequest request)
Handles
ValidationException instances. |
protected ResponseEntity<Object> |
handleExceptionInternal(Exception ex,
Object body,
HttpHeaders headers,
HttpStatus status,
WebRequest request) |
ResponseEntity |
handleHttpException(HttpException e,
WebRequest request)
Handles
HttpException instances. |
ResponseEntity |
handleThrowable(Throwable t,
WebRequest request)
Handles
Throwable instances. |
ResponseEntity |
handleValidationException(ValidationException e,
WebRequest request)
Handles
ValidationException instances. |
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, handleTypeMismatch
public HawaiiResponseEntityExceptionHandler(ValidationErrorResourceAssembler validationErrorResourceAssembler, ExceptionResponseFactory exceptionResponseFactory)
public void afterPropertiesSet() throws Exception
afterPropertiesSet
in interface InitializingBean
Exception
@ExceptionHandler(value=HttpException.class) @ResponseBody public ResponseEntity handleHttpException(HttpException e, 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 ResponseEntity handleValidationException(ValidationException e, WebRequest request)
ValidationException
instances.
The response status is: 400 Bad Request.
e
- the exceptionrequest
- the current request@ExceptionHandler(value=ApiException.class) @ResponseBody public ResponseEntity handleApiException(ApiException e, 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 ResponseEntity handleThrowable(Throwable t, WebRequest request)
Throwable
instances. This method acts as a fallback handler.t
- the exceptionrequest
- the current requestprotected ResponseEntity<Object> handleExceptionInternal(Exception ex, Object body, HttpHeaders headers, HttpStatus status, WebRequest request)
handleExceptionInternal
in class ResponseEntityExceptionHandler
protected ErrorResponseResource buildErrorResponseBody(Throwable throwable, HttpStatus status, 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 configureResponseEnrichers()
Subclasses may override this method to remove existing or add additional listeners,
using addResponseEnricher(ErrorResponseEnricher)
and removeResponseEnricher(ErrorResponseEnricher)
.
protected Collection<ErrorResponseEnricher> getResponseEnrichers()