mirror of
https://github.com/jrnl-org/jrnl.git
synced 2025-05-17 11:38:32 +02:00
replace sys.exit call with new exception handling
This commit is contained in:
parent
6a4915c393
commit
c5fc211ae9
3 changed files with 6 additions and 4 deletions
|
@ -197,9 +197,9 @@ def get_journal_name(args, config):
|
|||
args.text = args.text[1:]
|
||||
|
||||
if args.journal_name not in config["journals"]:
|
||||
print("No default journal configured.", file=sys.stderr)
|
||||
print(list_journals(config), file=sys.stderr)
|
||||
sys.exit(1)
|
||||
raise JrnlException(
|
||||
Message(MsgText.NoDefaultJournal, MsgType.ERROR, { "journals": list_journals(config)}),
|
||||
)
|
||||
|
||||
logging.debug("Using journal name: %s", args.journal_name)
|
||||
return args
|
||||
|
|
|
@ -67,6 +67,8 @@ class MsgText(Enum):
|
|||
{template}
|
||||
"""
|
||||
|
||||
NoDefaultJournal = "No default journal configured\n{journals}"
|
||||
|
||||
# --- Journal status ---#
|
||||
JournalNotSaved = "Entry NOT saved to journal"
|
||||
|
||||
|
|
|
@ -30,7 +30,7 @@ def list_journals(configuration):
|
|||
from . import config
|
||||
|
||||
"""List the journals specified in the configuration file"""
|
||||
result = f"Journals defined in {config.get_config_path()}\n"
|
||||
result = f"Journals defined in config ({config.get_config_path()})\n"
|
||||
ml = min(max(len(k) for k in configuration["journals"]), 20)
|
||||
for journal, cfg in configuration["journals"].items():
|
||||
result += " * {:{}} -> {}\n".format(
|
||||
|
|
Loading…
Add table
Reference in a new issue