From 17127a92fa5834e04bc0848d2b5cedd2dad2f210 Mon Sep 17 00:00:00 2001 From: GaMeNu <98153342+GaMeNu@users.noreply.github.com> Date: Sun, 5 Nov 2023 20:26:29 +0200 Subject: [PATCH] v2.2.4 More errlogging.py updts --- errlogging.py | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/errlogging.py b/errlogging.py index 92b7651..d9a3094 100644 --- a/errlogging.py +++ b/errlogging.py @@ -26,7 +26,21 @@ class ErrLogger: time = datetime.datetime.now() path = os.path.join(errlog_dir, f'ERRLOG_{time.strftime("%Y-%m-%d_%H-%M-%S")}.txt') - tb_str = '\n'.join(traceback.format_tb(e.__traceback__)) + tb_str = '' + + context_ls = list() + context_ls.append(e) + + ctx = e.__context__ + + while ctx is not None: + context_ls.append(ctx) + + context_str = '\n'.join([context.__str__() for context in context_ls]) + + tb_str = '\n\n'.join( + ['\n'.join(traceback.format_tb(exc.__traceback__)) for exc in context_ls] + ) data = f"""An error has occurred! Don't worry, I saved an automatic log for ya :) ---------------------------------------------------------------------- @@ -37,7 +51,7 @@ Error Info: {type(e).__name__}: {e} Context: -{e.__context__} +{context_str} Caused by: {e.__cause__}