use of org.springframework.web.bind.annotation.ExceptionHandler in project dhis2-core by dhis2.
the class CsdController method soapError.
@ExceptionHandler
public void soapError(SoapException ex, HttpServletResponse response) throws JAXBException, IOException {
Envelope envelope = new Envelope();
envelope.setHeader(null);
envelope.getBody().setFault(new Fault());
envelope.getBody().getFault().getCode().getValue().setValue(ex.getFaultCode());
envelope.getBody().getFault().getReason().getText().setValue(ex.getMessage());
response.setContentType(SOAP_CONTENT_TYPE);
marshaller.marshal(envelope, response.getOutputStream());
}
use of org.springframework.web.bind.annotation.ExceptionHandler in project cuba by cuba-platform.
the class RestControllerExceptionHandler method handleException.
@ExceptionHandler(Exception.class)
@ResponseBody
public ResponseEntity<ErrorInfo> handleException(Exception e) {
log.error("Exception in REST controller", e);
ErrorInfo errorInfo = new ErrorInfo("Server error", "");
return new ResponseEntity<>(errorInfo, HttpStatus.INTERNAL_SERVER_ERROR);
}
use of org.springframework.web.bind.annotation.ExceptionHandler in project cuba by cuba-platform.
the class RestControllerExceptionHandler method handleCustomValidationException.
@ExceptionHandler(CustomValidationException.class)
@ResponseBody
public ResponseEntity<List<ConstraintViolationInfo>> handleCustomValidationException(CustomValidationException e) {
log.debug("CustomValidationException: {}", e.getMessage());
ConstraintViolationInfo errorInfo = new ConstraintViolationInfo();
errorInfo.setPath("");
errorInfo.setInvalidValue(null);
errorInfo.setMessage(e.getLocalizedMessage());
errorInfo.setMessageTemplate("{com.haulmont.cuba.core.global.validation.CustomValidationException}");
return new ResponseEntity<>(Collections.singletonList(errorInfo), HttpStatus.BAD_REQUEST);
}
use of org.springframework.web.bind.annotation.ExceptionHandler in project cuba by cuba-platform.
the class RestControllerExceptionHandler method handleRowLevelSecurityException.
@ExceptionHandler(RowLevelSecurityException.class)
@ResponseBody
public ResponseEntity<ErrorInfo> handleRowLevelSecurityException(RowLevelSecurityException e) {
log.error("RowLevelSecurityException in service", e);
ErrorInfo errorInfo = new ErrorInfo("Forbidden", e.getMessage());
return new ResponseEntity<>(errorInfo, HttpStatus.FORBIDDEN);
}
use of org.springframework.web.bind.annotation.ExceptionHandler in project ArachneCentralAPI by OHDSI.
the class ExceptionHandlingController method exceptionHandler.
@ExceptionHandler(WrongFileFormatException.class)
public ResponseEntity<JsonResult> exceptionHandler(WrongFileFormatException ex) {
LOGGER.error(ex.getMessage(), ex);
JsonResult result = new JsonResult<>(VALIDATION_ERROR);
result.setErrorMessage(ex.getMessage());
result.getValidatorErrors().put(ex.getField(), ex.getMessage());
return new ResponseEntity<>(result, HttpStatus.OK);
}
Aggregations