move exception for no editor configured into new handling

This commit is contained in:
Jonathan Wren 2022-02-19 17:47:31 -08:00
parent e181302ca4
commit 782adef681
2 changed files with 12 additions and 11 deletions

View file

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

View file

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