Skip to content

Commit 1f5ed10

Browse files
authored
chore: handle request exceptions in send_get_http_raw (#475)
Signed-off-by: behnazh-w <[email protected]>
1 parent 13206e5 commit 1f5ed10

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/macaron/util.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,13 +72,17 @@ def send_get_http_raw(url: str, headers: dict | None = None, timeout: int | None
7272
7373
Returns
7474
-------
75-
Response
75+
Response | None
7676
The response object or None if there is an error.
7777
"""
7878
logger.debug("GET - %s", url)
79-
response = requests.get(
80-
url=url, headers=headers, timeout=timeout or defaults.getint("requests", "timeout", fallback=10)
81-
) # nosec B113:request_without_timeout
79+
try:
80+
response = requests.get(
81+
url=url, headers=headers, timeout=timeout or defaults.getint("requests", "timeout", fallback=10)
82+
) # nosec B113:request_without_timeout
83+
except requests.exceptions.RequestException as error:
84+
logger.debug(error)
85+
return None
8286
while response.status_code != 200:
8387
logger.error(
8488
"Receiving error code %s from server. Message: %s.",

0 commit comments

Comments
 (0)