From 6a4915c393ad060566332da54a60f89efc1109ab Mon Sep 17 00:00:00 2001 From: Jonathan Wren Date: Sat, 12 Mar 2022 14:32:20 -0800 Subject: [PATCH] replace sys.exit call with new exception handling --- jrnl/jrnl.py | 6 +----- jrnl/messages.py | 6 ++++++ 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/jrnl/jrnl.py b/jrnl/jrnl.py index 7dede648..4e824f85 100644 --- a/jrnl/jrnl.py +++ b/jrnl/jrnl.py @@ -200,11 +200,7 @@ def _get_editor_template(config, **kwargs): logging.debug("Write mode: template loaded: %s", template) except OSError: logging.error("Write mode: template not loaded") - print( - f"[Could not read template at '{config['template']}']", - file=sys.stderr, - ) - sys.exit(1) + raise JrnlException(Message(MsgText.CantReadTemplate, MsgType.ERROR, { "template": config["template"] })) return template diff --git a/jrnl/messages.py b/jrnl/messages.py index 056e1d1f..340e7b69 100644 --- a/jrnl/messages.py +++ b/jrnl/messages.py @@ -61,6 +61,12 @@ class MsgText(Enum): KeyboardInterruptMsg = "Aborted by user" + CantReadTemplate = """ + Unreadable template + Could not read template file at: + {template} + """ + # --- Journal status ---# JournalNotSaved = "Entry NOT saved to journal"