From e73bc5507c3c08363896a111a4508d546ee7b53b Mon Sep 17 00:00:00 2001 From: kramo <93832451+kra-mo@users.noreply.github.com> Date: Mon, 26 Jun 2023 10:56:01 +0200 Subject: [PATCH] Change display of errors --- src/importer/importer.py | 21 +++++++++++++-------- src/store/managers/sgdb_manager.py | 4 ++-- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/src/importer/importer.py b/src/importer/importer.py index ac71dca..6fb41b3 100644 --- a/src/importer/importer.py +++ b/src/importer/importer.py @@ -218,7 +218,14 @@ class Importer(ErrorProducer): errors.extend(manager.collect_errors()) # Filter out non friendly errors - errors = list(filter(lambda error: isinstance(error, FriendlyError), errors)) + errors = set( + tuple( + (error.title, error.subtitle) + for error in ( + filter(lambda error: isinstance(error, FriendlyError), errors) + ) + ) + ) # No error to display if not errors: @@ -235,9 +242,8 @@ class Importer(ErrorProducer): dialog.set_transient_for(shared.win) if len(errors) == 1: - # Display the single error in the dialog body - error = errors[0] - dialog.set_body(f"{error.title}\n{error.subtitle}") + dialog.set_heading((error := next(iter(errors)))[0]) + dialog.set_body(error[1]) else: # Display the errors in a list list_box = Gtk.ListBox() @@ -246,13 +252,12 @@ class Importer(ErrorProducer): list_box.set_margin_top(16) for error in errors: row = Adw.ActionRow() - row.set_title(error.title) - row.set_subtitle(error.subtitle) + row.set_title(error[0]) + row.set_subtitle(error[1]) list_box.append(row) - dialog.set_body(_("The following errors occured during import")) + dialog.set_body(_("The following errors occured during import:")) dialog.set_extra_child(list_box) - # Dialog is ready, present it dialog.present() def create_summary_toast(self): diff --git a/src/store/managers/sgdb_manager.py b/src/store/managers/sgdb_manager.py index 20e339a..b535381 100644 --- a/src/store/managers/sgdb_manager.py +++ b/src/store/managers/sgdb_manager.py @@ -44,6 +44,6 @@ class SGDBManager(AsyncManager): # If invalid auth, cancel all SGDBManager tasks self.cancellable.cancel() raise FriendlyError( - "Couldn't authenticate to SteamGridDB", - "Verify your API key in the preferences", + "Couldn't authenticate SteamGridDB", + "Verify your API key in preferences", ) from error