use of org.springframework.web.bind.annotation.ExceptionHandler in project ArachneCentralAPI by OHDSI.
the class ExceptionHandlingController method exceptionHandler.
@ExceptionHandler(NotEmptyException.class)
public ResponseEntity<JsonResult> exceptionHandler(NotEmptyException ex) {
LOGGER.error(ex.getMessage(), ex);
JsonResult result = new JsonResult<>(DEPENDENCY_EXISTS);
result.setErrorMessage(ex.getMessage());
return new ResponseEntity<>(result, HttpStatus.OK);
}
use of org.springframework.web.bind.annotation.ExceptionHandler in project ArachneCentralAPI by OHDSI.
the class ExceptionHandlingController method exceptionHandler.
@ExceptionHandler(FieldException.class)
public ResponseEntity<JsonResult> exceptionHandler(FieldException ex) {
LOGGER.error(ex.getMessage(), ex);
JsonResult result = new JsonResult<>(VALIDATION_ERROR);
result.setErrorMessage("Incorrect data");
result.getValidatorErrors().put(ex.getField(), ex.getMessage());
return new ResponseEntity<>(result, HttpStatus.OK);
}
use of org.springframework.web.bind.annotation.ExceptionHandler in project ArachneCentralAPI by OHDSI.
the class ExceptionHandlingController method exceptionHandler.
@ExceptionHandler(ValidationException.class)
public ResponseEntity<JsonResult> exceptionHandler(ValidationException ex) {
LOGGER.warn(ex.getMessage());
JsonResult result = new JsonResult<>(VALIDATION_ERROR);
result.setErrorMessage(ex.getMessage());
return new ResponseEntity<>(result, HttpStatus.OK);
}
use of org.springframework.web.bind.annotation.ExceptionHandler in project ArachneCentralAPI by OHDSI.
the class ExceptionHandlingController method exceptionHandler.
@ExceptionHandler(IOException.class)
public ResponseEntity<JsonResult> exceptionHandler(IOException ex) {
LOGGER.error(ex.getMessage(), ex);
JsonResult result = new JsonResult<>(SYSTEM_ERROR);
result.setErrorMessage(ex.getMessage());
return new ResponseEntity<>(result, HttpStatus.OK);
}
use of org.springframework.web.bind.annotation.ExceptionHandler in project ArachneCentralAPI by OHDSI.
the class ExceptionHandlingController method exceptionHandler.
@ExceptionHandler(BindException.class)
public ResponseEntity<JsonResult> exceptionHandler(BindException ex) {
LOGGER.warn(ex.getMessage());
JsonResult result = new JsonResult<>(VALIDATION_ERROR);
result.setErrorMessage("Incorrect data");
if (ex.hasErrors()) {
ex.getFieldErrors().forEach(er -> result.getValidatorErrors().put(er.getField(), er.getDefaultMessage()));
}
return new ResponseEntity<>(result, HttpStatus.OK);
}
Aggregations