Class ControllerExceptionHandler
- java.lang.Object
-
- ca.corefacility.bioinformatics.irida.web.controller.api.exception.ControllerExceptionHandler
-
@ControllerAdvice(basePackages="ca.corefacility.bioinformatics.irida.web.controller.api") public class ControllerExceptionHandler extends java.lang.Object
Globally handles exceptions thrown by controllers.
-
-
Constructor Summary
Constructors Constructor Description ControllerExceptionHandler()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description org.springframework.http.ResponseEntity<ErrorResponse>
handleAccessDeniedException(org.springframework.security.access.AccessDeniedException e)
HandleAccessDeniedException
.org.springframework.http.ResponseEntity<ErrorResponse>
handleAllOtherExceptions(java.lang.Exception e)
HandleException
.org.springframework.http.ResponseEntity<ErrorResponse>
handleArgumentException(java.lang.IllegalArgumentException e)
HandleIllegalArgumentException
.org.springframework.http.ResponseEntity<java.util.Map<java.lang.String,java.util.List<java.lang.String>>>
handleConstraintViolations(javax.validation.ConstraintViolationException e)
HandleConstraintViolationException
.org.springframework.http.ResponseEntity<ErrorResponse>
handleExistsException(EntityExistsException e)
HandleEntityExistsException
.org.springframework.http.ResponseEntity<ErrorResponse>
handleInvalidJsonException(org.springframework.http.converter.HttpMessageNotReadableException e)
HandleJsonParseException
.org.springframework.http.ResponseEntity<ErrorResponse>
handleInvalidPropertyException(InvalidPropertyException e)
HandleInvalidPropertyException
.org.springframework.http.ResponseEntity<ErrorResponse>
handleMediaTypeNotSupportedException(org.springframework.web.HttpMediaTypeNotSupportedException e)
Handle a HttpMediaTypeNotSupportedException exception.org.springframework.http.ResponseEntity<ErrorResponse>
handleMethodNotSupportedException(org.springframework.web.HttpRequestMethodNotSupportedException e)
HandleHttpRequestMethodNotSupportedException
.org.springframework.http.ResponseEntity<ErrorResponse>
handleNotFoundException(EntityNotFoundException e)
HandleEntityNotFoundException
.
-
-
-
Method Detail
-
handleAllOtherExceptions
@ExceptionHandler(java.lang.Exception.class) public org.springframework.http.ResponseEntity<ErrorResponse> handleAllOtherExceptions(java.lang.Exception e)
HandleException
.- Parameters:
e
- the exception as thrown by the service.- Returns:
- an appropriate HTTP response.
-
handleInvalidPropertyException
@ExceptionHandler(InvalidPropertyException.class) public org.springframework.http.ResponseEntity<ErrorResponse> handleInvalidPropertyException(InvalidPropertyException e)
HandleInvalidPropertyException
.- Parameters:
e
- the exception as thrown by the service.- Returns:
- an appropriate HTTP response.
-
handleNotFoundException
@ExceptionHandler(EntityNotFoundException.class) public org.springframework.http.ResponseEntity<ErrorResponse> handleNotFoundException(EntityNotFoundException e)
HandleEntityNotFoundException
.- 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)
HandleIllegalArgumentException
.- 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)
HandleConstraintViolationException
.- Parameters:
e
- the exception as thrown by the service.- Returns:
- an appropriate HTTP response.
-
handleExistsException
@ExceptionHandler(EntityExistsException.class) public org.springframework.http.ResponseEntity<ErrorResponse> handleExistsException(EntityExistsException e)
HandleEntityExistsException
.- 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)
HandleHttpRequestMethodNotSupportedException
.- 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)
HandleJsonParseException
.- 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)
HandleAccessDeniedException
.- Parameters:
e
- the exception thrown by spring security.- Returns:
- a forbidden response.
-
-