From 429fb59f0eb140cc64bd0404537c3a1f948af1bc Mon Sep 17 00:00:00 2001 From: Matan Shati <> Date: Mon, 19 Sep 2022 17:28:44 +0300 Subject: [PATCH] send exception log when exceeded retries --- checkov/common/util/http_utils.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/checkov/common/util/http_utils.py b/checkov/common/util/http_utils.py index bbbab6e963b..192f4952fbd 100644 --- a/checkov/common/util/http_utils.py +++ b/checkov/common/util/http_utils.py @@ -141,22 +141,24 @@ def request_wrapper( return response except requests.exceptions.ConnectionError as connection_error: logging.error(f"Connection error on request {method}:{url},\ndata:\n{data}\njson:{json}\nheaders:{headers}") - logging.exception("request_wrapper connection error") if i != request_max_tries - 1: sleep_secs = sleep_between_request_tries * (i + 1) logging.info(f"retrying attempt number {i + 2} in {sleep_secs} seconds") time.sleep(sleep_secs) continue + + logging.exception("request_wrapper connection error") raise connection_error except requests.exceptions.HTTPError as http_error: status_code = http_error.response.status_code logging.error(f"HTTP error on request {method}:{url},\ndata:\n{data}\njson:{json}\nheaders:{headers}") - logging.exception("request_wrapper http error") if (status_code >= 500 or status_code == 403) and i != request_max_tries - 1: sleep_secs = sleep_between_request_tries * (i + 1) logging.info(f"retrying attempt number {i + 2} in {sleep_secs} seconds") time.sleep(sleep_secs) continue + + logging.exception("request_wrapper http error") raise http_error else: raise Exception("Unexpected behavior: the method \'request_wrapper\' should be terminated inside the above for-"