From 535703a8f7b1eb0da962df46f8ab3ecd2935a5c1 Mon Sep 17 00:00:00 2001 From: bashrc Date: Sat, 25 Apr 2026 17:37:13 +0100 Subject: [PATCH] Optionally show exception text --- data.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/data.py b/data.py index 16fb75f8d..10081ae31 100644 --- a/data.py +++ b/data.py @@ -16,7 +16,9 @@ def _store_base(text: str, filename: str, exception_text: str, with open(filename, mode, encoding='utf-8') as fp: fp.write(text) return True - except OSError: + except OSError as exc: + if '[ex]' in exception_text: + exception_text = exception_text.replace('[ex]', str(exc)) print(exception_text) return False @@ -28,7 +30,9 @@ def load_string(filename: str, exception_text: str) -> str: with open(filename, 'r', encoding='utf-8') as fp: text = fp.read() return text - except OSError: + except OSError as exc: + if '[ex]' in exception_text: + exception_text = exception_text.replace('[ex]', str(exc)) print(exception_text) return None