use of uk.nhs.adaptors.scr.exceptions.OperationOutcomeError in project summary-care-record-api by NHSDigital.
the class OperationOutcomeExceptionHandler method handleAllExceptions.
@ExceptionHandler(Exception.class)
public ResponseEntity<Object> handleAllExceptions(Exception ex) {
LOGGER.error("Error occurred: {}", ex.getMessage());
OperationOutcome operationOutcome;
HttpStatus httpStatus;
if (ex instanceof OperationOutcomeError) {
OperationOutcomeError error = (OperationOutcomeError) ex;
operationOutcome = error.getOperationOutcome();
httpStatus = error.getStatusCode();
} else {
operationOutcome = createOperationOutcome(EXCEPTION, ERROR, ex.getMessage());
httpStatus = INTERNAL_SERVER_ERROR;
}
return errorResponse(new HttpHeaders(), httpStatus, operationOutcome);
}
Aggregations