Skip to content

Commit

Permalink
try/except around pprint
Browse files Browse the repository at this point in the history
  • Loading branch information
mcmonkey4eva committed Sep 11, 2024
1 parent 8d10a72 commit 400b5ae
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions action.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,13 +189,17 @@ def send_payload_to_api(args, output_files_gcs_paths, logs_gcs_path, workflow_na
# Send POST request
headers = {"Content-Type": "application/json"}
response = requests.post(args.api_endpoint, headers=headers, data=payload_json)
print("#### Payload ####")
pprint.pprint(payload)
print("#### Response ####")
try:
pprint.pprint(response.json())
except json.JSONDecodeError:
print(f"Invalid JSON: {response.text}")
print("#### Payload ####")
pprint.pprint(payload)
print("#### Response ####")
try:
pprint.pprint(response.json())
except json.JSONDecodeError:
print(f"Invalid JSON: {response.text}")
except:
# can sometimes have random encoding errors here
traceback.print_exc()

# Write response to application.log
log_file_path = "./application.log"
Expand Down

0 comments on commit 400b5ae

Please sign in to comment.