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
Modifier and TypeFieldDescriptionprotected final org.springframework.context.MessageSource
Fields inherited from class org.springframework.web.servlet.mvc.method.annotation.ResponseEntityExceptionHandler
logger, PAGE_NOT_FOUND_LOG_CATEGORY, pageNotFoundLogger
-
Constructor Summary
ModifierConstructorDescriptionprotected
RestExceptionHandler
(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, especiallyBaseApplicationException
and 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:
handleMissingServletRequestParameter
in 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:
handleHttpMessageNotReadable
in 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:
handleMethodArgumentNotValid
in 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:
handleNoHandlerFoundException
in 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, especiallyBaseApplicationException
and its descendents and use the exception's message.- Parameters:
ex
- The exceptionrequest
- Request object, to create response body.status
- The error status- Returns:
- A
ResponseEntity
object 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
ResponseEntity
object that's the response
-