replace sys.exit call with new exception handling

This commit is contained in:
Jonathan Wren 2022-03-12 14:32:20 -08:00
parent 66ce8debe5
commit 6a4915c393
2 changed files with 7 additions and 5 deletions

View file

@ -200,11 +200,7 @@ def _get_editor_template(config, **kwargs):
logging.debug("Write mode: template loaded: %s", template) logging.debug("Write mode: template loaded: %s", template)
except OSError: except OSError:
logging.error("Write mode: template not loaded") logging.error("Write mode: template not loaded")
print( raise JrnlException(Message(MsgText.CantReadTemplate, MsgType.ERROR, { "template": config["template"] }))
f"[Could not read template at '{config['template']}']",
file=sys.stderr,
)
sys.exit(1)
return template return template

View file

@ -61,6 +61,12 @@ class MsgText(Enum):
KeyboardInterruptMsg = "Aborted by user" KeyboardInterruptMsg = "Aborted by user"
CantReadTemplate = """
Unreadable template
Could not read template file at:
{template}
"""
# --- Journal status ---# # --- Journal status ---#
JournalNotSaved = "Entry NOT saved to journal" JournalNotSaved = "Entry NOT saved to journal"