fix(sca): send exception log when exceeded retries
send exception log when exceeded retries
@@ -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-"
