From ab8a05ac1b66d38d85688abfa814d7bc55dfed4a Mon Sep 17 00:00:00 2001 From: jacob1 Date: Wed, 19 Oct 2016 21:01:29 -0400 Subject: [PATCH] log errors to errors.log again --- messages/en.json | 1 + src/decorators.py | 6 +++--- src/utilities.py | 9 +-------- 3 files changed, 5 insertions(+), 11 deletions(-) diff --git a/messages/en.json b/messages/en.json index 5e8f506..979ecad 100644 --- a/messages/en.json +++ b/messages/en.json @@ -862,6 +862,7 @@ "quit_warning": "Quitting IRC during game. You only have a short time to re-join the channel after quitting to stay alive.", "acc_warning": "Changing accounts during game. Please do not change accounts while playing.", "tempban_kick": "{nick}", + "error_log": "An error has occurred and has been logged.", "_": " vim: set sw=4 expandtab:" } diff --git a/src/decorators.py b/src/decorators.py index 40f3305..639010f 100644 --- a/src/decorators.py +++ b/src/decorators.py @@ -50,11 +50,11 @@ class handle_error: cli = None if cli is not None: - msg = "An error has occurred and has been logged." if not botconfig.PASTEBIN_ERRORS or botconfig.CHANNEL != botconfig.DEV_CHANNEL: - cli.msg(botconfig.CHANNEL, msg) + cli.msg(botconfig.CHANNEL, messages["error_log"]) + errlog(traceback.format_exc()) if botconfig.PASTEBIN_ERRORS and botconfig.DEV_CHANNEL: - pastebin_tb(cli, msg, traceback.format_exc()) + pastebin_tb(cli, messages["error_log"], traceback.format_exc()) class cmd: def __init__(self, *cmds, raw_nick=False, flag=None, owner_only=False, diff --git a/src/utilities.py b/src/utilities.py index 0798d77..ccc7979 100644 --- a/src/utilities.py +++ b/src/utilities.py @@ -482,15 +482,8 @@ def pastebin_tb(cli, msg, exc): resp = urllib.request.urlopen(req) data = json.loads(resp.read().decode("utf-8")) url = data["url"] + "/py3tb" - except urllib.error.HTTPError as e: - if e.code == 409: # paste ID conflict - pastebin_tb(exc) # retry - else: - # Make sure we print the exception anyway - traceback.print_exc() - cli.msg(botconfig.DEV_CHANNEL, msg + " (Unable to pastebin traceback; please check the console.)") except Exception: - traceback.print_exc() + # Exception is already printed before calling this function, don't print twice cli.msg(botconfig.DEV_CHANNEL, msg + " (Unable to pastebin traceback; please check the console.)") else: cli.msg(botconfig.DEV_CHANNEL, " ".join((msg, url)))