Package org.imageconverter.infra
Class RestExceptionHandler
java.lang.Object
org.springframework.web.servlet.mvc.method.annotation.ResponseEntityExceptionHandler
org.imageconverter.infra.RestExceptionHandler
@ControllerAdvice
public class RestExceptionHandler
extends org.springframework.web.servlet.mvc.method.annotation.ResponseEntityExceptionHandler
This class handle exceptions and create response properly.
- Author:
- Fernando Romulo da Silva
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final org.springframework.context.MessageSourceFields inherited from class org.springframework.web.servlet.mvc.method.annotation.ResponseEntityExceptionHandler
logger, PAGE_NOT_FOUND_LOG_CATEGORY, pageNotFoundLogger -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedRestExceptionHandler(org.springframework.context.MessageSource messageSource) Default constructor. -
Method Summary
Modifier and TypeMethodDescriptionprotected org.springframework.http.ResponseEntity<Object>handleHttpMessageNotReadable(org.springframework.http.converter.HttpMessageNotReadableException ex, org.springframework.http.HttpHeaders headers, org.springframework.http.HttpStatus status, org.springframework.web.context.request.WebRequest request) protected org.springframework.http.ResponseEntity<Object>handleMethodArgumentNotValid(org.springframework.web.bind.MethodArgumentNotValidException ex, org.springframework.http.HttpHeaders headers, org.springframework.http.HttpStatus status, org.springframework.web.context.request.WebRequest request) protected org.springframework.http.ResponseEntity<Object>handleMissingServletRequestParameter(org.springframework.web.bind.MissingServletRequestParameterException ex, org.springframework.http.HttpHeaders headers, org.springframework.http.HttpStatus status, org.springframework.web.context.request.WebRequest request) protected org.springframework.http.ResponseEntity<Object>handleNoHandlerFoundException(org.springframework.web.servlet.NoHandlerFoundException ex, org.springframework.http.HttpHeaders headers, org.springframework.http.HttpStatus status, org.springframework.web.context.request.WebRequest request) protected org.springframework.http.ResponseEntity<Object>handleObjectException(String msg, Collection<Map<String, String>> subErrors, Throwable ex, org.springframework.web.context.request.WebRequest request, org.springframework.http.HttpStatus status) Handle exceptions using the message on response.protected org.springframework.http.ResponseEntity<Object>handleObjectException(Throwable ex, org.springframework.web.context.request.WebRequest request, org.springframework.http.HttpStatus status) Handle exceptions, especiallyBaseApplicationExceptionand its descendents and use the exception's message.Methods inherited from class org.springframework.web.servlet.mvc.method.annotation.ResponseEntityExceptionHandler
handleAsyncRequestTimeoutException, handleBindException, handleConversionNotSupported, handleException, handleExceptionInternal, handleHttpMediaTypeNotAcceptable, handleHttpMediaTypeNotSupported, handleHttpMessageNotWritable, handleHttpRequestMethodNotSupported, handleMissingPathVariable, handleMissingServletRequestPart, handleServletRequestBindingException, handleTypeMismatch
-
Field Details
-
messageSource
protected final org.springframework.context.MessageSource messageSource
-
-
Constructor Details
-
RestExceptionHandler
protected RestExceptionHandler(org.springframework.context.MessageSource messageSource) Default constructor.- Parameters:
messageSource- Object used to translate messages
-
-
Method Details
-
handleMissingServletRequestParameter
protected org.springframework.http.ResponseEntity<Object> handleMissingServletRequestParameter(org.springframework.web.bind.MissingServletRequestParameterException ex, org.springframework.http.HttpHeaders headers, org.springframework.http.HttpStatus status, org.springframework.web.context.request.WebRequest request) - Overrides:
handleMissingServletRequestParameterin classorg.springframework.web.servlet.mvc.method.annotation.ResponseEntityExceptionHandler
-
handleHttpMessageNotReadable
protected org.springframework.http.ResponseEntity<Object> handleHttpMessageNotReadable(org.springframework.http.converter.HttpMessageNotReadableException ex, org.springframework.http.HttpHeaders headers, org.springframework.http.HttpStatus status, org.springframework.web.context.request.WebRequest request) - Overrides:
handleHttpMessageNotReadablein classorg.springframework.web.servlet.mvc.method.annotation.ResponseEntityExceptionHandler
-
handleMethodArgumentNotValid
protected org.springframework.http.ResponseEntity<Object> handleMethodArgumentNotValid(org.springframework.web.bind.MethodArgumentNotValidException ex, org.springframework.http.HttpHeaders headers, org.springframework.http.HttpStatus status, org.springframework.web.context.request.WebRequest request) - Overrides:
handleMethodArgumentNotValidin classorg.springframework.web.servlet.mvc.method.annotation.ResponseEntityExceptionHandler
-
handleNoHandlerFoundException
protected org.springframework.http.ResponseEntity<Object> handleNoHandlerFoundException(org.springframework.web.servlet.NoHandlerFoundException ex, org.springframework.http.HttpHeaders headers, org.springframework.http.HttpStatus status, org.springframework.web.context.request.WebRequest request) - Overrides:
handleNoHandlerFoundExceptionin classorg.springframework.web.servlet.mvc.method.annotation.ResponseEntityExceptionHandler
-
handleObjectException
protected org.springframework.http.ResponseEntity<Object> handleObjectException(Throwable ex, org.springframework.web.context.request.WebRequest request, org.springframework.http.HttpStatus status) Handle exceptions, especiallyBaseApplicationExceptionand its descendents and use the exception's message.- Parameters:
ex- The exceptionrequest- Request object, to create response body.status- The error status- Returns:
- A
ResponseEntityobject that's the response
-
handleObjectException
protected org.springframework.http.ResponseEntity<Object> handleObjectException(String msg, Collection<Map<String, String>> subErrors, Throwable ex, org.springframework.web.context.request.WebRequest request, org.springframework.http.HttpStatus status) Handle exceptions using the message on response.- Parameters:
msg- The message that it'll be usedex- The exceptionrequest- Request object, to create response body.status- The error status- Returns:
- A
ResponseEntityobject that's the response
-