mirror of
https://github.com/jrnl-org/jrnl.git
synced 2025-07-11 09:36:14 +02:00
replace sys.exit call with new exception handling
This commit is contained in:
parent
c5fc211ae9
commit
548ac582d9
2 changed files with 13 additions and 5 deletions
|
@ -110,9 +110,9 @@ class MsgText(Enum):
|
|||
https://github.com/jrnl-org/jrnl/issues/new?title=JournalFailedUpgrade
|
||||
"""
|
||||
|
||||
UpgradeAborted = """
|
||||
jrnl was NOT upgraded
|
||||
"""
|
||||
UpgradeAborted = "jrnl was NOT upgraded"
|
||||
|
||||
ImportAborted = "Entries were NOT imported"
|
||||
|
||||
# -- Config --- #
|
||||
AltConfigNotFound = """
|
||||
|
|
|
@ -4,6 +4,11 @@
|
|||
|
||||
import sys
|
||||
|
||||
from jrnl.exception import JrnlException
|
||||
from jrnl.messages import Message
|
||||
from jrnl.messages import MsgText
|
||||
from jrnl.messages import MsgType
|
||||
|
||||
|
||||
class JRNLImporter:
|
||||
"""This plugin imports entries from other jrnl files."""
|
||||
|
@ -22,8 +27,11 @@ class JRNLImporter:
|
|||
try:
|
||||
other_journal_txt = sys.stdin.read()
|
||||
except KeyboardInterrupt:
|
||||
print("[Entries NOT imported into journal.]", file=sys.stderr)
|
||||
sys.exit(0)
|
||||
raise JrnlException(
|
||||
Message(MsgText.KeyboardInterruptMsg, MsgType.ERROR),
|
||||
Message(MsgText.ImportAborted, MsgType.WARNING),
|
||||
)
|
||||
|
||||
journal.import_(other_journal_txt)
|
||||
new_cnt = len(journal.entries)
|
||||
print(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue