Show a user-facing message instead of a traceback on invalid file type

While our importing dialog limits the types of files that can be selected,
users can also import by providing a filename on the command line.
This commit is contained in:
Damien Elmes 2022-05-05 21:24:12 +10:00
parent ac1cbaf719
commit 72389b97be
2 changed files with 6 additions and 1 deletions

View File

@ -87,3 +87,4 @@ importing-processed-notes =
[one] Processed { $count } note...
*[other] Processed { $count } notes...
}
importing-unable-to-import-filename = Unable to import { $filename }: file type not supported

View File

@ -25,7 +25,11 @@ def import_file(mw: aqt.main.AnkiQt, path: str) -> None:
elif filename.endswith(".apkg"):
import_anki_package(mw, path)
else:
raise NotImplementedError
showWarning(
tr.importing_unable_to_import_filename(filename=filename),
parent=mw,
textFormat="plain",
)
def prompt_for_file_then_import(mw: aqt.main.AnkiQt) -> None: