Search in sources :

Example 1 with BadRequestException

use of uk.nhs.adaptors.scr.exceptions.BadRequestException in project summary-care-record-api by NHSDigital.

the class AlertService method sendAlert.

public void sendAlert(String body, String nhsdAsid, String nhsdIdentity, String nhsdSessionUrid) {
    Response<String> response = spineClient.sendAlert(body, nhsdAsid, nhsdIdentity, nhsdSessionUrid);
    HttpStatus status = HttpStatus.resolve(response.getStatusCode());
    if (status == null || !status.is2xxSuccessful()) {
        OperationOutcome error = fhirParser.parseResource(response.getBody(), OperationOutcome.class);
        if (status != null && status.is4xxClientError()) {
            LOGGER.error("Spine processing error: {}", status);
            throw new BadRequestException(getErrorReason(error));
        } else {
            LOGGER.error("Spine processing error: {}", getErrorReason(error));
            throw new UnexpectedSpineResponseException(getErrorReason(error));
        }
    }
}
Also used : UnexpectedSpineResponseException(uk.nhs.adaptors.scr.exceptions.UnexpectedSpineResponseException) HttpStatus(org.springframework.http.HttpStatus) OperationOutcome(org.hl7.fhir.r4.model.OperationOutcome) BadRequestException(uk.nhs.adaptors.scr.exceptions.BadRequestException)

Aggregations

OperationOutcome (org.hl7.fhir.r4.model.OperationOutcome)1 HttpStatus (org.springframework.http.HttpStatus)1 BadRequestException (uk.nhs.adaptors.scr.exceptions.BadRequestException)1 UnexpectedSpineResponseException (uk.nhs.adaptors.scr.exceptions.UnexpectedSpineResponseException)1