use of com.odysseusinc.arachne.commons.api.v1.dto.util.JsonResult 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 com.odysseusinc.arachne.commons.api.v1.dto.util.JsonResult 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 com.odysseusinc.arachne.commons.api.v1.dto.util.JsonResult 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 com.odysseusinc.arachne.commons.api.v1.dto.util.JsonResult 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);
}
use of com.odysseusinc.arachne.commons.api.v1.dto.util.JsonResult in project ArachneCentralAPI by OHDSI.
the class ExceptionHandlingController method exceptionHandler.
@ExceptionHandler(MethodArgumentNotValidException.class)
public ResponseEntity<JsonResult> exceptionHandler(MethodArgumentNotValidException ex) {
LOGGER.warn(ex.getMessage());
JsonResult result = new JsonResult<>(VALIDATION_ERROR);
if (ex.getBindingResult().hasErrors()) {
result = setValidationErrors(ex.getBindingResult());
}
return new ResponseEntity<>(result, HttpStatus.OK);
}
Aggregations