From c46f861de0908b5bc37c564e559319a37d3d95cd Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Mon, 16 Apr 2018 11:15:54 +0200 Subject: [PATCH] Catch more exceptions --- utils.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/utils.py b/utils.py index cbd9017..959d210 100644 --- a/utils.py +++ b/utils.py @@ -4,6 +4,18 @@ import time from configloader import config from strings import currency_format_string, currency_symbol 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: @@ -111,6 +123,9 @@ def catch_telegram_errors(func): # Unknown error except telegram.error.TelegramError: 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