add new exception handling to 'nothing saved to file' errors

This commit is contained in:
Jonathan Wren 2022-02-19 17:31:59 -08:00
parent 35cdd7bd59
commit e181302ca4
4 changed files with 8 additions and 4 deletions

View file

@ -37,7 +37,7 @@ def get_text_from_editor(config, template=""):
os.remove(tmpfile) os.remove(tmpfile)
if not raw: if not raw:
print("[Nothing saved to file]", file=sys.stderr) raise JrnlException(JrnlExceptionMessage.NoTextReceived)
return raw return raw

View file

@ -51,7 +51,11 @@ class JrnlExceptionMessage(Enum):
NothingToDelete = """ NothingToDelete = """
No entries to delete, because the search returned no results. No entries to delete, because the search returned no results.
""" """
NoTextReceived = """
Nothing saved to file.
"""
UpgradeAborted = """ UpgradeAborted = """
jrnl was NOT upgraded jrnl was NOT upgraded

View file

@ -136,7 +136,7 @@ def write_mode(args, config, journal, **kwargs):
if not raw: if not raw:
logging.error("Write mode: couldn't get raw text") logging.error("Write mode: couldn't get raw text")
sys.exit() raise JrnlException(JrnlExceptionMessage.NoTextReceived)
logging.debug( logging.debug(
'Write mode: appending raw text to journal "%s": %s', args.journal_name, raw 'Write mode: appending raw text to journal "%s": %s', args.journal_name, raw

View file

@ -78,7 +78,7 @@ Feature: Writing new entries.
And we write nothing to the editor if opened And we write nothing to the editor if opened
And we use the password "test" if prompted And we use the password "test" if prompted
When we run "jrnl --edit" When we run "jrnl --edit"
Then the error output should contain "[Nothing saved to file]" Then the error output should contain "Nothing saved to file"
And the editor should have been called And the editor should have been called
Examples: configs Examples: configs