Skip to content

Commit

Permalink
Update error handling bug
Browse files Browse the repository at this point in the history
Signed-off-by: Tanner Lewis <lewijacn@amazon.com>
  • Loading branch information
lewijacn committed Sep 18, 2024
1 parent ec3a2ed commit c895bd4
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions webhook-trigger/default_webhook_trigger.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,19 +135,19 @@ def trigger_and_wait_for_job(jenkins_url: str, pipeline_token: str, payload: dic
else:
response.raise_for_status()

except requests.exceptions.RequestException as e:
except requests.exceptions.RequestException as request_exception:
if response is None:
response_body = "{}"
else:
try:
response_body = response.json()
except Exception as e:
logging.warning(f"Unable to parse trigger request response with error: {e}")
except Exception as parse_exception:
logging.warning(f"Unable to parse trigger request response, does this endpoint return a proper json response? Error: {parse_exception}")
response_body = "{}"
logging.error(f"Failed to trigger webhook for URL: {jenkins_webhook_url} and payload: {payload} with "
f"response body: {response_body}")
logging.info(f"{action_result_name}: FAILURE")
raise e
raise request_exception
except Exception as e:
logging.info(f"{action_result_name}: FAILURE")
raise e
Expand Down

0 comments on commit c895bd4

Please sign in to comment.