aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Numerlor <[email protected]>2020-05-07 01:45:28 +0200
committerGravatar Numerlor <[email protected]>2020-05-07 01:45:28 +0200
commit93a805d950f9daf14ba50131547d888e1f6314b3 (patch)
treebec29a4f4589f1aed2c6e1ab53024fc4c97c6a72
parentContinue on failed connections. (diff)
Handle broad exceptions.
In the case an unexpected exception happens, this allows us to try the request again or let the function exit gracefully in the case of multiple fails.
-rw-r--r--bot/utils/__init__.py7
1 files changed, 7 insertions, 0 deletions
diff --git a/bot/utils/__init__.py b/bot/utils/__init__.py
index 41e54c3d5..b9290e5a6 100644
--- a/bot/utils/__init__.py
+++ b/bot/utils/__init__.py
@@ -40,6 +40,13 @@ async def send_to_paste_service(http_session: ClientSession, contents: str, *, e
f"trying again ({attempt}/{FAILED_REQUEST_ATTEMPTS})."
)
continue
+ except Exception:
+ log.exception(
+ f"An unexpected error has occurred during handling of the request, "
+ f"trying again ({attempt}/{FAILED_REQUEST_ATTEMPTS})."
+ )
+ continue
+
if "message" in response_json:
log.warning(f"Paste service returned error {response_json['message']} with status code {response.status}.")
return