diff options
| author | 2020-05-07 01:45:28 +0200 | |
|---|---|---|
| committer | 2020-05-07 01:45:28 +0200 | |
| commit | 93a805d950f9daf14ba50131547d888e1f6314b3 (patch) | |
| tree | bec29a4f4589f1aed2c6e1ab53024fc4c97c6a72 | |
| parent | Continue 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__.py | 7 | 
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 | 
