Skip to content
This repository has been archived by the owner on Jul 25, 2024. It is now read-only.

Commit

Permalink
[BAU] improve exception handling and logging when posting to /ingest
Browse files Browse the repository at this point in the history
  • Loading branch information
cyrusdobbs committed Nov 17, 2023
1 parent bec881a commit 6289801
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions app/main/data_requests.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,13 @@ def post_ingest(file: FileStorage, data: dict = None) -> tuple[bool, dict | None
request_url = Config.DATA_STORE_API_HOST + "/ingest"
files = {"excel_file": (file.name, file, MIMETYPE.XLSX)}

current_app.logger.info("POST sent to data-store /ingest")
response = requests.post(request_url, files=files, data=data)
current_app.logger.info(f"Sending POST to {request_url}")
try:
response = requests.post(request_url, files=files, data=data)
except ConnectionError:
current_app.logger.error(f"Attempted POST to {request_url} but connection failed")
abort(500)

file.seek(0) # reset the stream position
response_json = response.json()

Expand Down

0 comments on commit 6289801

Please sign in to comment.