diff --git a/jrnl/commands.py b/jrnl/commands.py index 5ba449e4b..468dc742d 100644 --- a/jrnl/commands.py +++ b/jrnl/commands.py @@ -76,7 +76,17 @@ def postconfig_import(args: argparse.Namespace, config: dict, **_) -> int: journal = open_journal(args.journal_name, config) format = args.export if args.export else "jrnl" - get_importer(format).import_(journal, args.filename) + + if (importer := get_importer(format)) is None: + raise JrnlException( + Message( + MsgText.ImporterNotFound, + MsgStyle.ERROR, + {"format": format}, + ) + ) + + importer.import_(journal, args.filename) return 0 diff --git a/jrnl/messages/MsgText.py b/jrnl/messages/MsgText.py index 9361781d7..14eb8c2f5 100644 --- a/jrnl/messages/MsgText.py +++ b/jrnl/messages/MsgText.py @@ -266,6 +266,11 @@ def __str__(self) -> str: {count} imported to {journal_name} journal """ + ImporterNotFound = """ + No importer found for file type '{format}'. + '{format}' is likely to be an export-only format. + """ + # --- Color --- # InvalidColor = "{key} set to invalid color: {color}"