diff options
| author | 2020-05-07 01:51:27 +0200 | |
|---|---|---|
| committer | 2020-05-07 01:51:27 +0200 | |
| commit | 8f7551540cc2770b498bfe38a9f72c0950bbd929 (patch) | |
| tree | dcaa7469893671320fe8b17e7fd294f65d514599 | |
| parent | Handle broad exceptions. (diff) | |
continue on internal server errors.
In the case we receive `"message"` in the json response,
the server had an internal error and we can attempt the request again.
| -rw-r--r-- | bot/utils/__init__.py | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/bot/utils/__init__.py b/bot/utils/__init__.py index b9290e5a6..b273b2cde 100644 --- a/bot/utils/__init__.py +++ b/bot/utils/__init__.py @@ -48,8 +48,11 @@ async def send_to_paste_service(http_session: ClientSession, contents: str, *, e continue if "message" in response_json: - log.warning(f"Paste service returned error {response_json['message']} with status code {response.status}.") - return + log.warning( + f"Paste service returned error {response_json['message']} with status code {response.status}, " + f"trying again ({attempt}/{FAILED_REQUEST_ATTEMPTS})." + ) + continue elif "key" in response_json: log.info(f"Successfully uploaded contents to paste service behind key {response_json['key']}.") return URLs.paste_service.format(key=response_json['key']) + extension |