Class ControllerExceptionHandler


  • @ControllerAdvice(basePackages="ca.corefacility.bioinformatics.irida.web.controller.api")
    public class ControllerExceptionHandler
    extends java.lang.Object
    Globally handles exceptions thrown by controllers.
    • Constructor Detail

      • ControllerExceptionHandler

        public ControllerExceptionHandler()
    • Method Detail

      • handleAllOtherExceptions

        @ExceptionHandler(java.lang.Exception.class)
        public org.springframework.http.ResponseEntity<ErrorResponse> handleAllOtherExceptions​(java.lang.Exception e)
        Handle Exception.
        Parameters:
        e - the exception as thrown by the service.
        Returns:
        an appropriate HTTP response.
      • handleArgumentException

        @ExceptionHandler(java.lang.IllegalArgumentException.class)
        public org.springframework.http.ResponseEntity<ErrorResponse> handleArgumentException​(java.lang.IllegalArgumentException e)
        Handle IllegalArgumentException .
        Parameters:
        e - the exception as thrown by the service.
        Returns:
        an appropriate HTTP response.
      • handleConstraintViolations

        @ExceptionHandler(javax.validation.ConstraintViolationException.class)
        public org.springframework.http.ResponseEntity<java.util.Map<java.lang.String,​java.util.List<java.lang.String>>> handleConstraintViolations​(javax.validation.ConstraintViolationException e)
        Handle ConstraintViolationException.
        Parameters:
        e - the exception as thrown by the service.
        Returns:
        an appropriate HTTP response.
      • handleMethodNotSupportedException

        @ExceptionHandler(org.springframework.web.HttpRequestMethodNotSupportedException.class)
        public org.springframework.http.ResponseEntity<ErrorResponse> handleMethodNotSupportedException​(org.springframework.web.HttpRequestMethodNotSupportedException e)
        Handle HttpRequestMethodNotSupportedException.
        Parameters:
        e - the exception as thrown by Spring.
        Returns:
        an appropriate HTTP response.
      • handleMediaTypeNotSupportedException

        @ExceptionHandler(org.springframework.web.HttpMediaTypeNotSupportedException.class)
        public org.springframework.http.ResponseEntity<ErrorResponse> handleMediaTypeNotSupportedException​(org.springframework.web.HttpMediaTypeNotSupportedException e)
        Handle a HttpMediaTypeNotSupportedException exception. Returns a HTTP 415 and a list of the acceptable types
        Parameters:
        e - the exception to handle
        Returns:
        A response entity stating the type is unsupported
      • handleInvalidJsonException

        @ExceptionHandler(org.springframework.http.converter.HttpMessageNotReadableException.class)
        public org.springframework.http.ResponseEntity<ErrorResponse> handleInvalidJsonException​(org.springframework.http.converter.HttpMessageNotReadableException e)
        Handle JsonParseException.
        Parameters:
        e - the exception as thrown by the JSON parser.
        Returns:
        an appropriate HTTP response.
      • handleAccessDeniedException

        @ExceptionHandler(org.springframework.security.access.AccessDeniedException.class)
        public org.springframework.http.ResponseEntity<ErrorResponse> handleAccessDeniedException​(org.springframework.security.access.AccessDeniedException e)
        Handle AccessDeniedException.
        Parameters:
        e - the exception thrown by spring security.
        Returns:
        a forbidden response.