Class ApiExceptionHandler


  • @ControllerAdvice
    public class ApiExceptionHandler
    extends org.springframework.web.servlet.mvc.method.annotation.ResponseEntityExceptionHandler
    • Field Summary

      • Fields inherited from class org.springframework.web.servlet.mvc.method.annotation.ResponseEntityExceptionHandler

        logger, PAGE_NOT_FOUND_LOG_CATEGORY, pageNotFoundLogger
    • Constructor Summary

      Constructors 
      Constructor Description
      ApiExceptionHandler​(org.springframework.context.MessageSource messageSource)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      org.springframework.http.ResponseEntity handleBeanValidation​(BeanValidationException ex, org.springframework.web.context.request.WebRequest request)  
      protected org.springframework.http.ResponseEntity handleBindException​(org.springframework.validation.BindException ex, org.springframework.http.HttpHeaders headers, org.springframework.http.HttpStatus status, org.springframework.web.context.request.WebRequest request)  
      org.springframework.http.ResponseEntity handleCrudException​(CrudException ex, org.springframework.http.HttpHeaders headers, org.springframework.http.HttpStatus status, org.springframework.web.context.request.WebRequest request)  
      org.springframework.http.ResponseEntity handleDataIntegrityException​(DataIntegrityException ex, org.springframework.web.context.request.WebRequest request)  
      protected org.springframework.http.ResponseEntity 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)  
      protected org.springframework.http.ResponseEntity handleHttpMessageNotReadable​(org.springframework.http.converter.HttpMessageNotReadableException ex, org.springframework.http.HttpHeaders headers, org.springframework.http.HttpStatus status, org.springframework.web.context.request.WebRequest request)  
      org.springframework.http.ResponseEntity handleIllegalArgumentException​(java.lang.IllegalArgumentException ex, org.springframework.web.context.request.WebRequest request)  
      org.springframework.http.ResponseEntity handleInvalidFormatException​(com.fasterxml.jackson.databind.exc.InvalidFormatException ex, org.springframework.http.HttpHeaders headers, org.springframework.http.HttpStatus status, org.springframework.web.context.request.WebRequest request)  
      org.springframework.http.ResponseEntity handleMethodArgumentNotValid​(org.springframework.web.bind.MethodArgumentNotValidException ex, org.springframework.http.HttpHeaders headers, org.springframework.http.HttpStatus status, org.springframework.web.context.request.WebRequest request)  
      org.springframework.http.ResponseEntity handleMethodArgumentTypeMismatchException​(org.springframework.web.method.annotation.MethodArgumentTypeMismatchException ex, org.springframework.http.HttpHeaders headers, org.springframework.http.HttpStatus status, org.springframework.web.context.request.WebRequest request)  
      protected org.springframework.http.ResponseEntity handleNoHandlerFoundException​(org.springframework.web.servlet.NoHandlerFoundException ex, org.springframework.http.HttpHeaders headers, org.springframework.http.HttpStatus status, org.springframework.web.context.request.WebRequest request)  
      org.springframework.http.ResponseEntity handleNotFoundException​(NotFoundException ex, org.springframework.web.context.request.WebRequest request)  
      org.springframework.http.ResponseEntity handlePropertyBindingException​(com.fasterxml.jackson.databind.exc.PropertyBindingException ex, org.springframework.http.HttpHeaders headers, org.springframework.http.HttpStatus status, org.springframework.web.context.request.WebRequest request)  
      org.springframework.http.ResponseEntity handlePropertyReferenceException​(org.springframework.data.mapping.PropertyReferenceException ex, org.springframework.http.HttpHeaders headers, org.springframework.web.context.request.WebRequest request)  
      org.springframework.http.ResponseEntity handleResponseStatusException​(org.springframework.web.server.ResponseStatusException ex, org.springframework.web.context.request.WebRequest request)  
      protected org.springframework.http.ResponseEntity handleTypeMismatch​(org.springframework.beans.TypeMismatchException ex, org.springframework.http.HttpHeaders headers, org.springframework.http.HttpStatus status, org.springframework.web.context.request.WebRequest request)  
      org.springframework.http.ResponseEntity handleUncaught​(java.lang.Exception ex, org.springframework.web.context.request.WebRequest request)  
      • Methods inherited from class org.springframework.web.servlet.mvc.method.annotation.ResponseEntityExceptionHandler

        handleAsyncRequestTimeoutException, handleConversionNotSupported, handleException, handleHttpMediaTypeNotAcceptable, handleHttpMediaTypeNotSupported, handleHttpMessageNotWritable, handleHttpRequestMethodNotSupported, handleMissingPathVariable, handleMissingServletRequestParameter, handleMissingServletRequestPart, handleServletRequestBindingException
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • ApiExceptionHandler

        public ApiExceptionHandler​(org.springframework.context.MessageSource messageSource)
    • Method Detail

      • handleUncaught

        @ExceptionHandler(java.lang.Exception.class)
        public org.springframework.http.ResponseEntity handleUncaught​(java.lang.Exception ex,
                                                                      org.springframework.web.context.request.WebRequest request)
      • handleCrudException

        @ExceptionHandler(CrudException.class)
        public org.springframework.http.ResponseEntity handleCrudException​(CrudException ex,
                                                                           org.springframework.http.HttpHeaders headers,
                                                                           org.springframework.http.HttpStatus status,
                                                                           org.springframework.web.context.request.WebRequest request)
      • handlePropertyReferenceException

        @ExceptionHandler(org.springframework.data.mapping.PropertyReferenceException.class)
        public org.springframework.http.ResponseEntity handlePropertyReferenceException​(org.springframework.data.mapping.PropertyReferenceException ex,
                                                                                        org.springframework.http.HttpHeaders headers,
                                                                                        org.springframework.web.context.request.WebRequest request)
      • handleHttpMessageNotReadable

        protected org.springframework.http.ResponseEntity 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 class org.springframework.web.servlet.mvc.method.annotation.ResponseEntityExceptionHandler
      • handleInvalidFormatException

        @ExceptionHandler(com.fasterxml.jackson.databind.exc.InvalidFormatException.class)
        public org.springframework.http.ResponseEntity handleInvalidFormatException​(com.fasterxml.jackson.databind.exc.InvalidFormatException ex,
                                                                                    org.springframework.http.HttpHeaders headers,
                                                                                    org.springframework.http.HttpStatus status,
                                                                                    org.springframework.web.context.request.WebRequest request)
      • handlePropertyBindingException

        @ExceptionHandler(com.fasterxml.jackson.databind.exc.PropertyBindingException.class)
        public org.springframework.http.ResponseEntity handlePropertyBindingException​(com.fasterxml.jackson.databind.exc.PropertyBindingException ex,
                                                                                      org.springframework.http.HttpHeaders headers,
                                                                                      org.springframework.http.HttpStatus status,
                                                                                      org.springframework.web.context.request.WebRequest request)
      • handleTypeMismatch

        protected org.springframework.http.ResponseEntity handleTypeMismatch​(org.springframework.beans.TypeMismatchException ex,
                                                                             org.springframework.http.HttpHeaders headers,
                                                                             org.springframework.http.HttpStatus status,
                                                                             org.springframework.web.context.request.WebRequest request)
        Overrides:
        handleTypeMismatch in class org.springframework.web.servlet.mvc.method.annotation.ResponseEntityExceptionHandler
      • handleMethodArgumentTypeMismatchException

        public org.springframework.http.ResponseEntity handleMethodArgumentTypeMismatchException​(org.springframework.web.method.annotation.MethodArgumentTypeMismatchException ex,
                                                                                                 org.springframework.http.HttpHeaders headers,
                                                                                                 org.springframework.http.HttpStatus status,
                                                                                                 org.springframework.web.context.request.WebRequest request)
      • handleBindException

        protected org.springframework.http.ResponseEntity handleBindException​(org.springframework.validation.BindException ex,
                                                                              org.springframework.http.HttpHeaders headers,
                                                                              org.springframework.http.HttpStatus status,
                                                                              org.springframework.web.context.request.WebRequest request)
        Overrides:
        handleBindException in class org.springframework.web.servlet.mvc.method.annotation.ResponseEntityExceptionHandler
      • handleMethodArgumentNotValid

        public org.springframework.http.ResponseEntity 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 class org.springframework.web.servlet.mvc.method.annotation.ResponseEntityExceptionHandler
      • handleNoHandlerFoundException

        protected org.springframework.http.ResponseEntity 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 class org.springframework.web.servlet.mvc.method.annotation.ResponseEntityExceptionHandler
      • handleNotFoundException

        @ExceptionHandler(NotFoundException.class)
        public org.springframework.http.ResponseEntity handleNotFoundException​(NotFoundException ex,
                                                                               org.springframework.web.context.request.WebRequest request)
      • handleIllegalArgumentException

        @ExceptionHandler(java.lang.IllegalArgumentException.class)
        public org.springframework.http.ResponseEntity handleIllegalArgumentException​(java.lang.IllegalArgumentException ex,
                                                                                      org.springframework.web.context.request.WebRequest request)
      • handleResponseStatusException

        @ExceptionHandler(org.springframework.web.server.ResponseStatusException.class)
        public org.springframework.http.ResponseEntity handleResponseStatusException​(org.springframework.web.server.ResponseStatusException ex,
                                                                                     org.springframework.web.context.request.WebRequest request)
      • handleExceptionInternal

        protected org.springframework.http.ResponseEntity 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)
        Overrides:
        handleExceptionInternal in class org.springframework.web.servlet.mvc.method.annotation.ResponseEntityExceptionHandler