mirror of
https://github.com/Steffo99/greed.git
synced 2024-11-21 21:44:19 +00:00
Catch more exceptions
This commit is contained in:
parent
575ca37033
commit
c46f861de0
1 changed files with 15 additions and 0 deletions
15
utils.py
15
utils.py
|
@ -4,6 +4,18 @@ import time
|
||||||
from configloader import config
|
from configloader import config
|
||||||
from strings import currency_format_string, currency_symbol
|
from strings import currency_format_string, currency_symbol
|
||||||
import typing
|
import typing
|
||||||
|
import os
|
||||||
|
import sys
|
||||||
|
|
||||||
|
if config["Error Reporting"]["sentry_token"] != \
|
||||||
|
"https://00000000000000000000000000000000:00000000000000000000000000000000@sentry.io/0000000":
|
||||||
|
import raven
|
||||||
|
|
||||||
|
sentry_client = raven.Client(config["Error Reporting"]["sentry_token"],
|
||||||
|
release=raven.fetch_git_sha(os.path.dirname(__file__)),
|
||||||
|
environment="Dev" if __debug__ else "Prod")
|
||||||
|
else:
|
||||||
|
sentry_client = None
|
||||||
|
|
||||||
|
|
||||||
class Price:
|
class Price:
|
||||||
|
@ -111,6 +123,9 @@ def catch_telegram_errors(func):
|
||||||
# Unknown error
|
# Unknown error
|
||||||
except telegram.error.TelegramError:
|
except telegram.error.TelegramError:
|
||||||
print(f"Telegram error while calling {func.__name__}(), retrying in 5 secs...")
|
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)
|
time.sleep(5)
|
||||||
return result_func
|
return result_func
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue