From 782adef681b07dd1b97e406d2501b4c1996a2d3f Mon Sep 17 00:00:00 2001 From: Jonathan Wren Date: Sat, 19 Feb 2022 17:47:31 -0800 Subject: [PATCH] move exception for no editor configured into new handling --- jrnl/exception.py | 10 ++++++++++ jrnl/jrnl.py | 13 ++----------- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/jrnl/exception.py b/jrnl/exception.py index ae38e814..be5c7c23 100644 --- a/jrnl/exception.py +++ b/jrnl/exception.py @@ -61,6 +61,16 @@ class JrnlExceptionMessage(Enum): jrnl was NOT upgraded """ + EditorNotConfigured = """ + There is no editor configured. + + To use the --edit option, please specify an editor your config file: + {config_file} + + For examples of how to configure an external editor, see: + https://jrnl.sh/en/stable/external-editors/ + """ + SomeTest = """ Some error or something diff --git a/jrnl/jrnl.py b/jrnl/jrnl.py index 1b2d2954..0da0b57e 100644 --- a/jrnl/jrnl.py +++ b/jrnl/jrnl.py @@ -7,8 +7,6 @@ import sys from . import install from . import plugins from .Journal import open_journal -from .color import ERROR_COLOR -from .color import RESET_COLOR from .config import get_journal_name from .config import scope_config from .config import get_config_path @@ -241,16 +239,9 @@ def _edit_search_results(config, journal, old_entries, **kwargs): 3. Write modifications to journal """ if not config["editor"]: - print( - f""" - [{ERROR_COLOR}ERROR{RESET_COLOR}: There is no editor configured.] - - Please specify an editor in config file ({get_config_path()}) - to use the --edit option. - """, - file=sys.stderr, + raise JrnlException( + JrnlExceptionMessage.EditorNotConfigured, config_file=get_config_path() ) - sys.exit(1) # separate entries we are not editing other_entries = [e for e in old_entries if e not in journal.entries]