Skip to content

Commit

Permalink
Add error handling for failed requests in deidentify_text function
Browse files Browse the repository at this point in the history
  • Loading branch information
milanmlft committed Dec 14, 2023
1 parent fd899eb commit afc944a
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions pixl_ehr/src/pixl_ehr/report_deid/deid.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,16 @@ def deidentify_text(text: str) -> str:
response = requests.post(
COGSTACK_URL, data=text, headers={"Content-Type": "text/plain"}, timeout=10
)
success_code = 200

if response.status_code != success_code:
msg = (
f"Failed request. "
f"Status code: {response.status_code}"
f"Content: {response.content.decode()}"
)
raise requests.HTTPError(msg)

return response.text


Expand Down

0 comments on commit afc944a

Please sign in to comment.