From 72389b97be52bd6ad39fa27e088f6ca9d231d32f Mon Sep 17 00:00:00 2001 From: Damien Elmes Date: Thu, 5 May 2022 21:24:12 +1000 Subject: [PATCH] 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. --- ftl/core/importing.ftl | 1 + qt/aqt/import_export/importing.py | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/ftl/core/importing.ftl b/ftl/core/importing.ftl index 7bd57718f..6323ca602 100644 --- a/ftl/core/importing.ftl +++ b/ftl/core/importing.ftl @@ -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 diff --git a/qt/aqt/import_export/importing.py b/qt/aqt/import_export/importing.py index 6fdbe37a5..21d58a17d 100644 --- a/qt/aqt/import_export/importing.py +++ b/qt/aqt/import_export/importing.py @@ -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: