@ControllerAdvice public class JsonErrorHandler extends Object
Constructor and Description |
---|
JsonErrorHandler() |
Modifier and Type | Method and Description |
---|---|
JsonErrorResponse |
handleDuplicateKeyException(org.springframework.dao.DuplicateKeyException ex)
Catch DuplicateKeyException when an entity creation or update doesn't a constraint of uniqueness in the mongo repository.
|
JsonErrorResponse |
handleEntityNotFoundException(EntityNotFoundException ex)
Catch EntityNotFoundException to return a 404 error.
|
JsonErrorResponse |
handleHttpMessageNotReadableException(org.springframework.http.converter.HttpMessageNotReadableException ex)
Catch HttpMessageNotReadableException to log it (helps to diagnose errors and attacks on REST services).
|
JsonErrorResponse |
processValidationError(org.springframework.web.bind.MethodArgumentNotValidException ex)
Catch MethodArgumentNotValidException when a Bean Validation error occurs.
|
@ExceptionHandler(value=org.springframework.http.converter.HttpMessageNotReadableException.class) @RequestMapping(produces="application/json") @ResponseStatus(value=BAD_REQUEST) @ResponseBody public JsonErrorResponse handleHttpMessageNotReadableException(org.springframework.http.converter.HttpMessageNotReadableException ex) throws IOException
ex
- The exception trappedJsonErrorResponse
IOException
- if any.@ExceptionHandler(value=org.springframework.dao.DuplicateKeyException.class) @RequestMapping(produces="application/json") @ResponseStatus(value=CONFLICT) @ResponseBody public JsonErrorResponse handleDuplicateKeyException(org.springframework.dao.DuplicateKeyException ex) throws IOException
ex
- The exception trappedJsonErrorResponse
IOException
- if any.@ExceptionHandler(value=org.springframework.web.bind.MethodArgumentNotValidException.class) @RequestMapping(produces="application/json") @ResponseStatus(value=BAD_REQUEST) @ResponseBody public JsonErrorResponse processValidationError(org.springframework.web.bind.MethodArgumentNotValidException ex) throws IOException
ex
- The exception trappedJsonErrorResponse
IOException
- if any.@ExceptionHandler(value=EntityNotFoundException.class) @RequestMapping(produces="application/json") @ResponseStatus(value=NOT_FOUND) @ResponseBody public JsonErrorResponse handleEntityNotFoundException(EntityNotFoundException ex) throws IOException
ex
- The exception trappedJsonErrorResponse
IOException
- if any.Copyright © 2011–2016 eXo Platform SAS. All rights reserved.