Skip to content

Commit

Permalink
fix(fhir): report ECL syntax error details in FHIR operation outcomes
Browse files Browse the repository at this point in the history
  • Loading branch information
cmark committed May 7, 2024
1 parent e9d1866 commit 3b62aaf
Showing 1 changed file with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -237,8 +237,7 @@ protected static <T extends Resource> T toFhirResource(
return fhirResource.as(resourceClass);

} catch (FHIRParserException e) {
throw new BadRequestException(String.format("Failed to parse request body as a complete %s resource.",
resourceClass.getSimpleName()));
throw new BadRequestException(String.format("Failed to parse request body as a complete %s resource: %s", resourceClass.getSimpleName(), e.getMessage()));
}
}

Expand Down Expand Up @@ -323,6 +322,14 @@ protected static ResponseEntity<byte[]> toResponseEntity(
}
}

@ExceptionHandler
@ResponseStatus(HttpStatus.BAD_REQUEST)
public @ResponseBody OperationOutcome handle(final SyntaxException ex) {
FhirException fhirException = FhirException.createFhirError(ex.getMessage(), OperationOutcomeCode.MSG_BAD_SYNTAX);
fhirException.withAdditionalInfo(ex.getAdditionalInfo());
return fhirException.toOperationOutcome();
}

@ExceptionHandler
@ResponseStatus(HttpStatus.BAD_REQUEST)
public @ResponseBody OperationOutcome handle(final ValidationException ex) {
Expand Down

0 comments on commit 3b62aaf

Please sign in to comment.