From 5f7f5db0ff84c277ddc6c84218c739c76d730031 Mon Sep 17 00:00:00 2001 From: dece Date: Mon, 15 Aug 2022 14:26:09 +0200 Subject: [PATCH] bot: show traceback in debug logs on unhandled exc --- edmond/bot.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/edmond/bot.py b/edmond/bot.py index 494fc17..9255b54 100644 --- a/edmond/bot.py +++ b/edmond/bot.py @@ -3,6 +3,8 @@ import json import os import time import signal +import sys +import traceback from pathlib import Path from typing import Any, Iterable, Optional @@ -123,8 +125,11 @@ class Bot(irc.client.SimpleIRCClient, Logger): self.start() except KeyboardInterrupt: self.log_i("Caught keyboard interrupt.") - except Exception as exc: # Yes, I know, who are you going to call? + except Exception as exc: self.log_c(f"Caught unhandled exception: {exc}") + _, _, exc_traceback = sys.exc_info() + for line in traceback.format_tb(exc_traceback): + self.log_d(line.rstrip()) finally: self.cleanup()