[gnome-software/1425-bad-error-message-when-installing-broken-flatpakref-file] flatpak: Change error mapping for some codes to improve error reporting




commit e2559d698e918061ece63014a72ea10d26c79654
Author: Milan Crha <mcrha redhat com>
Date:   Wed Sep 8 21:39:34 2021 +0200

    flatpak: Change error mapping for some codes to improve error reporting
    
    The "not supported" error code completely hides the actual error, which
    is not good for the "not found" errors. Similarly, invalid data has its
    own error code on the plugin side.
    
    Closes https://gitlab.gnome.org/GNOME/gnome-software/-/issues/1425

 plugins/flatpak/gs-flatpak-utils.c | 6 ++++--
 plugins/flatpak/gs-self-test.c     | 2 +-
 2 files changed, 5 insertions(+), 3 deletions(-)
---
diff --git a/plugins/flatpak/gs-flatpak-utils.c b/plugins/flatpak/gs-flatpak-utils.c
index 05ee126cd..8b107b37c 100644
--- a/plugins/flatpak/gs-flatpak-utils.c
+++ b/plugins/flatpak/gs-flatpak-utils.c
@@ -41,13 +41,15 @@ gs_flatpak_error_convert (GError **perror)
                switch (error->code) {
                case FLATPAK_ERROR_ALREADY_INSTALLED:
                case FLATPAK_ERROR_NOT_INSTALLED:
-               case FLATPAK_ERROR_REMOTE_NOT_FOUND:
-               case FLATPAK_ERROR_RUNTIME_NOT_FOUND:
                        error->code = GS_PLUGIN_ERROR_NOT_SUPPORTED;
                        break;
                case FLATPAK_ERROR_OUT_OF_SPACE:
                        error->code = GS_PLUGIN_ERROR_NO_SPACE;
                        break;
+               case FLATPAK_ERROR_INVALID_REF:
+               case FLATPAK_ERROR_INVALID_DATA:
+                       error->code = GS_PLUGIN_ERROR_INVALID_FORMAT;
+                       break;
                default:
                        error->code = GS_PLUGIN_ERROR_FAILED;
                        break;
diff --git a/plugins/flatpak/gs-self-test.c b/plugins/flatpak/gs-self-test.c
index ee5d7050e..2789d4f70 100644
--- a/plugins/flatpak/gs-self-test.c
+++ b/plugins/flatpak/gs-self-test.c
@@ -613,7 +613,7 @@ gs_plugins_flatpak_app_missing_runtime_func (GsPluginLoader *plugin_loader)
                                         "app", app,
                                         NULL);
        ret = gs_plugin_loader_job_action (plugin_loader, plugin_job, NULL, &error);
-       g_assert_error (error, GS_PLUGIN_ERROR, GS_PLUGIN_ERROR_NOT_SUPPORTED);
+       g_assert_error (error, GS_PLUGIN_ERROR, GS_PLUGIN_ERROR_FAILED);
        g_assert_true (!ret);
        g_clear_error (&error);
        g_assert_cmpint (gs_app_get_state (app), ==, GS_APP_STATE_AVAILABLE);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]