Skip to content

Commit

Permalink
Capture and audit details from response bundle on error.
Browse files Browse the repository at this point in the history
  • Loading branch information
Paul F Bugni committed Oct 14, 2023
1 parent d154ab5 commit 87f4488
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions hydrant/models/bundle.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,15 +91,11 @@ def transmit_bundle(self):
try:
response.raise_for_status()
except requests.exceptions.HTTPError as http_err:
# at least one item in the bundle generated an unhappy code, track down
# the offenders and report
for upsert_entry, status_response in zip(fhir_bundle['entry'], response.json()['entry']):
if status_response['response']['status'] != "200 OK":
audit_entry(
f"upload error: {status_response['response']['status']}"
f" {status_response['response']['location']}:"
f" {upsert_entry}", level="error")
# at least one item in the bundle generated an error
audit_entry(f"response: {response.json()['issue']}", level="error")
logging.debug(f"fhir_bundle generated errors: {fhir_bundle}")
raise http_err

self.total_sent += len(self.bundle)
extra = {'tags': ['upload'], 'system': self.target_system, 'user': 'system'}
audit_entry(f"uploaded: {response.json()}", extra=extra)
Expand Down

0 comments on commit 87f4488

Please sign in to comment.