1
Fork 0
mirror of https://github.com/Steffo99/greed.git synced 2024-11-22 05:54:18 +00:00

Catch Bad Gateway Telegram errors

This commit is contained in:
Steffo 2018-04-26 08:15:18 +02:00
parent 762a672ce8
commit 22b63aa24f

View file

@ -128,12 +128,19 @@ def catch_telegram_errors(func):
print(f"Network error while calling {func.__name__}(), retrying in 5 secs...") print(f"Network error while calling {func.__name__}(), retrying in 5 secs...")
time.sleep(5) time.sleep(5)
# Unknown error # Unknown error
except telegram.error.TelegramError: except telegram.error.TelegramError as error:
print(f"Telegram error while calling {func.__name__}(), retrying in 5 secs...") if error.message.lower() == "bad gateway":
# Send the error to the Sentry server print(f"Bad Gateway while calling {func.__name__}(), retrying in 5 secs...")
if sentry_client is not None: time.sleep(5)
sentry_client.captureException(exc_info=sys.exc_info()) elif error.message.lower() == "timed out":
time.sleep(5) print(f"Timed out while calling {func.__name__}(), retrying in 1 sec...")
time.sleep(1)
else:
print(f"Telegram error while calling {func.__name__}(), retrying in 5 secs...")
# Send the error to the Sentry server
if sentry_client is not None:
sentry_client.captureException(exc_info=sys.exc_info())
time.sleep(5)
return result_func return result_func