From c2bed5869b50bef73ca5802d0a13801a2943159b Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Wed, 19 Sep 2018 01:23:04 +0200 Subject: [PATCH] Display the full error in debug mode --- utils.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/utils.py b/utils.py index b757511..ecce767 100644 --- a/utils.py +++ b/utils.py @@ -128,9 +128,12 @@ def catch_telegram_errors(func): f" retrying in {config['Telegram']['timed_out_pause']} secs...") time.sleep(int(config["Telegram"]["timed_out_pause"])) # Telegram is not reachable - except telegram.error.NetworkError: + except telegram.error.NetworkError as error: print(f"Network error while calling {func.__name__}()," f" retrying in {config['Telegram']['error_pause']} secs...") + # Display the full NetworkError if in debug mode + if __debug__: + print(f"Full error: {error.message}") time.sleep(int(config["Telegram"]["error_pause"])) # Unknown error except telegram.error.TelegramError as error: @@ -145,8 +148,11 @@ def catch_telegram_errors(func): else: print(f"Telegram error while calling {func.__name__}()," f" retrying in {config['Telegram']['error_pause']} secs...") + # Display the full TelegramError if in debug mode + if __debug__: + print(f"Full error: {error.message}") # Send the error to the Sentry server - if sentry_client is not None: + elif sentry_client is not None: sentry_client.captureException(exc_info=sys.exc_info()) time.sleep(int(config["Telegram"]["error_pause"])) return result_func