Optionally show exception text

main
bashrc 2026-04-25 17:37:13 +01:00
parent 61b4d8d5c1
commit 535703a8f7
1 changed files with 6 additions and 2 deletions

View File

@ -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