Catch keyboard interrupt when opening journal (#476)

If the journal is encrypted, jrnl asks for a password using the
getpass.getpass function. If user presses the keyboard interrupt (e.g.
ctrl+c) during the password prompt, jrnl crashes and prints a stack
trace. This however is not very user friendly.

This commit adds a check for KeyboardInterrupt Exception and prints a
message whenever this exception occurs and exits. Stack is no longer
printed.

Fixes #450
This commit is contained in:
Radomír Bosák 2017-03-10 17:54:02 +01:00
parent ca2d9f072f
commit 8fe8e00e1b

View file

@ -206,7 +206,11 @@ def run(manual_args=None):
mode_compose = False
# This is where we finally open the journal!
journal = Journal.open_journal(journal_name, config)
try:
journal = Journal.open_journal(journal_name, config)
except KeyboardInterrupt:
util.prompt("[Interrupted while opening journal]".format(journal_name))
sys.exit(1)
# Import mode
if mode_import: