[gnome-software] Enforce that plugins need to return errors of the correct domain



commit 5da646c93718a24eb48a49341ba9fee7b33cd922
Author: Richard Hughes <richard hughsie com>
Date:   Fri Sep 9 10:22:59 2016 +0100

    Enforce that plugins need to return errors of the correct domain

 doc/api/Makefile.am                            |    1 +
 src/Makefile.am                                |    4 +
 src/gs-plugin-loader.c                         |    6 +-
 src/gs-utils.c                                 |  165 ++++++++++++++++++++++++
 src/gs-utils.h                                 |    4 +
 src/plugins/Makefile.am                        |    5 +-
 src/plugins/gs-appstream.c                     |    9 +-
 src/plugins/gs-flatpak.c                       |  145 +++++++++++++++++----
 src/plugins/gs-plugin-appstream.c              |    4 +-
 src/plugins/gs-plugin-dpkg.c                   |    4 +-
 src/plugins/gs-plugin-dummy.c                  |    1 +
 src/plugins/gs-plugin-epiphany.c               |    8 +-
 src/plugins/gs-plugin-fedora-distro-upgrades.c |    4 +-
 src/plugins/gs-plugin-fwupd.c                  |   94 +++++++++++---
 src/plugins/gs-plugin-icons.c                  |   43 +++++--
 src/plugins/gs-plugin-odrs.c                   |   12 ++-
 src/plugins/gs-plugin-ostree.c                 |    8 +-
 src/plugins/gs-plugin-packagekit-refresh.c     |    2 +-
 src/plugins/gs-plugin-repos.c                  |   12 ++-
 src/plugins/gs-plugin-shell-extensions.c       |   25 +++-
 src/plugins/gs-plugin-steam.c                  |   55 ++++++--
 src/plugins/gs-plugin-systemd-updates.c        |   14 ++-
 src/plugins/gs-plugin-ubuntuone.c              |    4 +-
 src/plugins/packagekit-common.c                |    4 +-
 src/plugins/packagekit-common.h                |    2 +-
 25 files changed, 534 insertions(+), 101 deletions(-)
---
diff --git a/doc/api/Makefile.am b/doc/api/Makefile.am
index 293e844..c0241e4 100644
--- a/doc/api/Makefile.am
+++ b/doc/api/Makefile.am
@@ -78,6 +78,7 @@ GTKDOC_LIBS=                                                  \
        $(APPSTREAM_LIBS)                                       \
        $(LIBM)                                                 \
        $(LIBSECRET_LIBS)                                       \
+       $(JSON_GLIB_LIBS)                                       \
        $(GTK_LIBS)                                             \
        $(top_builddir)/src/gnome_software-gs-app-list.o        \
        $(top_builddir)/src/gnome_software-gs-app.o             \
diff --git a/src/Makefile.am b/src/Makefile.am
index 12055b5..ef5a302 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -10,6 +10,7 @@ AM_CPPFLAGS =                                         \
        $(PACKAGEKIT_CFLAGS)                            \
        $(GNOME_DESKTOP_CFLAGS)                         \
        $(POLKIT_CFLAGS)                                \
+       $(JSON_GLIB_CFLAGS)                             \
        $(LIBSECRET_CFLAGS)                             \
        -DG_LOG_DOMAIN=\"Gs\"                           \
        -DI_KNOW_THE_PACKAGEKIT_GLIB2_API_IS_SUBJECT_TO_CHANGE  \
@@ -128,6 +129,7 @@ gnome_software_cmd_LDADD =                          \
        $(LIBSECRET_LIBS)                               \
        $(GLIB_LIBS)                                    \
        $(GTK_LIBS)                                     \
+       $(JSON_GLIB_LIBS)                               \
        $(LIBM)
 
 gnome_software_cmd_CFLAGS =                            \
@@ -285,6 +287,7 @@ gnome_software_LDADD =                                      \
        $(PACKAGEKIT_LIBS)                              \
        $(GNOME_DESKTOP_LIBS)                           \
        $(POLKIT_LIBS)                                  \
+       $(JSON_GLIB_LIBS)                               \
        $(LIBM)
 
 gnome_software_CFLAGS =                                        \
@@ -359,6 +362,7 @@ gs_self_test_LDADD =                                                \
        $(LIBSECRET_LIBS)                                       \
        $(GLIB_LIBS)                                            \
        $(GTK_LIBS)                                             \
+       $(JSON_GLIB_LIBS)                                       \
        $(LIBM)
 
 gs_self_test_CFLAGS = $(WARN_CFLAGS)
diff --git a/src/gs-plugin-loader.c b/src/gs-plugin-loader.c
index 322eb0f..5b6c8fa 100644
--- a/src/gs-plugin-loader.c
+++ b/src/gs-plugin-loader.c
@@ -280,8 +280,12 @@ gs_plugin_loader_create_event_from_error (GsPluginLoader *plugin_loader,
        /* invalid */
        if (error == NULL)
                return;
-       if (error->domain != GS_PLUGIN_ERROR)
+       if (error->domain != GS_PLUGIN_ERROR) {
+               g_critical ("not GsPlugin error %s:%i",
+                           g_quark_to_string (error->domain),
+                           error->code);
                return;
+       }
 
        /* create plugin event */
        event = gs_plugin_event_new ();
diff --git a/src/gs-utils.c b/src/gs-utils.c
index 3146a1e..e3d0892 100644
--- a/src/gs-utils.c
+++ b/src/gs-utils.c
@@ -36,6 +36,7 @@
 #include <fnmatch.h>
 #include <math.h>
 #include <glib/gstdio.h>
+#include <json-glib/json-glib.h>
 
 #ifdef HAVE_POLKIT
 #include <polkit/polkit.h>
@@ -547,4 +548,168 @@ gs_utils_error_strip_unique_id (GError *error)
        error->message = str;
 }
 
+/**
+ * gs_utils_error_convert_gio:
+ * @perror: a pointer to a #GError, or %NULL
+ *
+ * Converts the #GIOError to an error with a GsPluginError domain.
+ *
+ * Returns: %TRUE if the error was converted
+ **/
+gboolean
+gs_utils_error_convert_gio (GError **perror)
+{
+       GError *error = perror != NULL ? *perror : NULL;
+
+       /* not set */
+       if (error == NULL)
+               return FALSE;
+       if (error->domain != G_IO_ERROR)
+               return FALSE;
+       error->domain = GS_PLUGIN_ERROR;
+       switch (error->code) {
+       case G_IO_ERROR_FAILED:
+               error->code = GS_PLUGIN_ERROR_FAILED;
+               break;
+       case G_IO_ERROR_NOT_SUPPORTED:
+               error->code = GS_PLUGIN_ERROR_NOT_SUPPORTED;
+               break;
+       case G_IO_ERROR_CANCELLED:
+               error->code = GS_PLUGIN_ERROR_CANCELLED;
+               break;
+       case G_IO_ERROR_NO_SPACE:
+               error->code = GS_PLUGIN_ERROR_NO_SPACE;
+               break;
+       case G_IO_ERROR_HOST_NOT_FOUND:
+       case G_IO_ERROR_HOST_UNREACHABLE:
+       case G_IO_ERROR_CONNECTION_REFUSED:
+       case G_IO_ERROR_PROXY_FAILED:
+       case G_IO_ERROR_PROXY_AUTH_FAILED:
+       case G_IO_ERROR_PROXY_NOT_ALLOWED:
+               error->code = GS_PLUGIN_ERROR_DOWNLOAD_FAILED;
+               break;
+       case G_IO_ERROR_NETWORK_UNREACHABLE:
+               error->code = GS_PLUGIN_ERROR_NO_NETWORK;
+               break;
+       default:
+               g_warning ("can't reliably fixup error code %i in domain %s",
+                          error->code, g_quark_to_string (error->domain));
+               error->code = GS_PLUGIN_ERROR_FAILED;
+               break;
+       }
+       return TRUE;
+}
+
+/**
+ * gs_utils_error_convert_gdk_pixbuf:
+ * @perror: a pointer to a #GError, or %NULL
+ *
+ * Converts the #GdkPixbufError to an error with a GsPluginError domain.
+ *
+ * Returns: %TRUE if the error was converted
+ **/
+gboolean
+gs_utils_error_convert_gdk_pixbuf (GError **perror)
+{
+       GError *error = perror != NULL ? *perror : NULL;
+
+       /* not set */
+       if (error == NULL)
+               return FALSE;
+       if (error->domain != GDK_PIXBUF_ERROR)
+               return FALSE;
+       error->domain = GS_PLUGIN_ERROR;
+       switch (error->code) {
+       case GDK_PIXBUF_ERROR_UNSUPPORTED_OPERATION:
+       case GDK_PIXBUF_ERROR_UNKNOWN_TYPE:
+               error->code = GS_PLUGIN_ERROR_NOT_SUPPORTED;
+               break;
+       case GDK_PIXBUF_ERROR_FAILED:
+               error->code = GS_PLUGIN_ERROR_FAILED;
+               break;
+       case GDK_PIXBUF_ERROR_CORRUPT_IMAGE:
+               error->code = GS_PLUGIN_ERROR_INVALID_FORMAT;
+               break;
+       default:
+               g_warning ("can't reliably fixup error code %i in domain %s",
+                          error->code, g_quark_to_string (error->domain));
+               error->code = GS_PLUGIN_ERROR_FAILED;
+               break;
+       }
+       return TRUE;
+}
+
+/**
+ * gs_utils_error_convert_json_glib:
+ * @perror: a pointer to a #GError, or %NULL
+ *
+ * Converts the #JsonParserError to an error with a GsPluginError domain.
+ *
+ * Returns: %TRUE if the error was converted
+ **/
+gboolean
+gs_utils_error_convert_json_glib (GError **perror)
+{
+       GError *error = perror != NULL ? *perror : NULL;
+
+       /* not set */
+       if (error == NULL)
+               return FALSE;
+       if (error->domain != JSON_PARSER_ERROR)
+               return FALSE;
+       error->domain = GS_PLUGIN_ERROR;
+       switch (error->code) {
+       case JSON_PARSER_ERROR_UNKNOWN:
+               error->code = GS_PLUGIN_ERROR_FAILED;
+       default:
+               error->code = GS_PLUGIN_ERROR_INVALID_FORMAT;
+               break;
+       }
+       return TRUE;
+}
+
+/**
+ * gs_utils_error_convert_appstream:
+ * @perror: a pointer to a #GError, or %NULL
+ *
+ * Converts the various AppStream error types to an error with a GsPluginError
+ * domain.
+ *
+ * Returns: %TRUE if the error was converted
+ **/
+void
+gs_utils_error_convert_appstream (GError **perror)
+{
+       GError *error = perror != NULL ? *perror : NULL;
+
+       /* not set */
+       if (error == NULL)
+               return;
+
+       /* custom to this plugin */
+       if (error->domain == AS_UTILS_ERROR) {
+               switch (error->code) {
+               case AS_UTILS_ERROR_INVALID_TYPE:
+                       error->code = GS_PLUGIN_ERROR_INVALID_FORMAT;
+                       break;
+               case AS_UTILS_ERROR_FAILED:
+               default:
+                       error->code = GS_PLUGIN_ERROR_FAILED;
+                       break;
+               }
+       } else if (error->domain == AS_STORE_ERROR) {
+               switch (error->code) {
+               case AS_UTILS_ERROR_FAILED:
+               default:
+                       error->code = GS_PLUGIN_ERROR_FAILED;
+                       break;
+               }
+       } else {
+               g_warning ("can't reliably fixup error from domain %s",
+                          g_quark_to_string (error->domain));
+               error->code = GS_PLUGIN_ERROR_FAILED;
+       }
+       error->domain = GS_PLUGIN_ERROR;
+}
+
 /* vim: set noexpandtab: */
diff --git a/src/gs-utils.h b/src/gs-utils.h
index cbf803a..b41cf72 100644
--- a/src/gs-utils.h
+++ b/src/gs-utils.h
@@ -73,6 +73,10 @@ gint          gs_utils_get_wilson_rating     (guint64         star1,
 void            gs_utils_error_add_unique_id   (GError         **error,
                                                 GsApp          *app);
 void            gs_utils_error_strip_unique_id (GError         *error);
+gboolean        gs_utils_error_convert_gio     (GError         **perror);
+gboolean        gs_utils_error_convert_gdk_pixbuf(GError       **perror);
+gboolean        gs_utils_error_convert_json_glib (GError       **perror);
+void            gs_utils_error_convert_appstream (GError       **perror);
 
 G_END_DECLS
 
diff --git a/src/plugins/Makefile.am b/src/plugins/Makefile.am
index 331a436..dadbe29 100644
--- a/src/plugins/Makefile.am
+++ b/src/plugins/Makefile.am
@@ -313,7 +313,10 @@ libgs_plugin_packagekit_local_la_LIBADD = $(GS_PLUGIN_LIBS) $(PACKAGEKIT_LIBS)
 libgs_plugin_packagekit_local_la_LDFLAGS = -module -avoid-version
 libgs_plugin_packagekit_local_la_CFLAGS = $(GS_PLUGIN_CFLAGS) $(WARN_CFLAGS)
 
-libgs_plugin_systemd_updates_la_SOURCES = gs-plugin-systemd-updates.c
+libgs_plugin_systemd_updates_la_SOURCES =              \
+       gs-plugin-systemd-updates.c                     \
+       packagekit-common.c                             \
+       packagekit-common.h
 libgs_plugin_systemd_updates_la_LIBADD = $(GS_PLUGIN_LIBS) $(PACKAGEKIT_LIBS)
 libgs_plugin_systemd_updates_la_LDFLAGS = -module -avoid-version
 libgs_plugin_systemd_updates_la_CFLAGS = $(GS_PLUGIN_CFLAGS) $(WARN_CFLAGS)
diff --git a/src/plugins/gs-appstream.c b/src/plugins/gs-appstream.c
index 22d4f33..d38c371 100644
--- a/src/plugins/gs-appstream.c
+++ b/src/plugins/gs-appstream.c
@@ -402,8 +402,10 @@ gs_appstream_refine_app_updates (GsPlugin *plugin,
                desc = as_markup_convert (as_release_get_description (rel, NULL),
                                          AS_MARKUP_CONVERT_FORMAT_SIMPLE,
                                          error);
-               if (desc == NULL)
+               if (desc == NULL) {
+                       gs_utils_error_convert_appstream (error);
                        return FALSE;
+               }
                gs_app_set_update_details (app, desc);
 
        /* get the descriptions with a version prefix */
@@ -415,8 +417,10 @@ gs_appstream_refine_app_updates (GsPlugin *plugin,
                        desc = as_markup_convert (as_release_get_description (rel, NULL),
                                                  AS_MARKUP_CONVERT_FORMAT_SIMPLE,
                                                  error);
-                       if (desc == NULL)
+                       if (desc == NULL) {
+                               gs_utils_error_convert_appstream (error);
                                return FALSE;
+                       }
                        g_string_append_printf (update_desc,
                                                "Version %s:\n%s\n\n",
                                                as_release_get_version (rel),
@@ -610,6 +614,7 @@ gs_appstream_refine_app (GsPlugin *plugin,
                g_autofree gchar *from_xml = NULL;
                from_xml = as_markup_convert_simple (tmp, error);
                if (from_xml == NULL) {
+                       gs_utils_error_convert_appstream (error);
                        g_prefix_error (error, "trying to parse '%s': ", tmp);
                        return FALSE;
                }
diff --git a/src/plugins/gs-flatpak.c b/src/plugins/gs-flatpak.c
index ca90abd..06ef951 100644
--- a/src/plugins/gs-flatpak.c
+++ b/src/plugins/gs-flatpak.c
@@ -51,6 +51,38 @@ gs_flatpak_refresh_appstream (GsFlatpak *self, guint cache_age,
                              GCancellable *cancellable, GError **error);
 
 static void
+gs_plugin_flatpak_error_convert (GError **perror)
+{
+       GError *error = perror != NULL ? *perror : NULL;
+
+       /* not set */
+       if (error == NULL)
+               return;
+
+       /* this are allowed for low-level errors */
+       if (gs_utils_error_convert_gio (perror))
+               return;
+
+       /* custom to this plugin */
+       if (error->domain == FLATPAK_ERROR) {
+               switch (error->code) {
+               case FLATPAK_ERROR_ALREADY_INSTALLED:
+               case FLATPAK_ERROR_NOT_INSTALLED:
+                       error->code = GS_PLUGIN_ERROR_NOT_SUPPORTED;
+                       break;
+               default:
+                       error->code = GS_PLUGIN_ERROR_FAILED;
+                       break;
+               }
+       } else {
+               g_warning ("can't reliably fixup error from domain %s",
+                          g_quark_to_string (error->domain));
+               error->code = GS_PLUGIN_ERROR_FAILED;
+       }
+       error->domain = GS_PLUGIN_ERROR;
+}
+
+static void
 gs_plugin_flatpak_changed_cb (GFileMonitor *monitor,
                              GFile *child,
                              GFile *other_file,
@@ -105,16 +137,19 @@ gs_flatpak_setup (GsFlatpak *self, GCancellable *cancellable, GError **error)
                self->installation = flatpak_installation_new_user (cancellable,
                                                                    error);
        }
-
-       if (self->installation == NULL)
+       if (self->installation == NULL) {
+               gs_plugin_flatpak_error_convert (error);
                return FALSE;
+       }
 
        /* watch for changes */
        self->monitor = flatpak_installation_create_monitor (self->installation,
                                                             cancellable,
                                                             error);
-       if (self->monitor == NULL)
+       if (self->monitor == NULL) {
+               gs_plugin_flatpak_error_convert (error);
                return FALSE;
+       }
        g_signal_connect (self->monitor, "changed",
                          G_CALLBACK (gs_plugin_flatpak_changed_cb), self);
 
@@ -137,8 +172,10 @@ gs_flatpak_refresh_appstream (GsFlatpak *self, guint cache_age,
 
        xremotes = flatpak_installation_list_remotes (self->installation, cancellable,
                                                      error);
-       if (xremotes == NULL)
+       if (xremotes == NULL) {
+               gs_plugin_flatpak_error_convert (error);
                return FALSE;
+       }
        for (i = 0; i < xremotes->len; i++) {
                const gchar *remote_name;
                guint tmp;
@@ -413,8 +450,10 @@ gs_flatpak_add_installed (GsFlatpak *self, GsAppList *list,
        /* get apps and runtimes */
        xrefs = flatpak_installation_list_installed_refs (self->installation,
                                                          cancellable, error);
-       if (xrefs == NULL)
+       if (xrefs == NULL) {
+               gs_plugin_flatpak_error_convert (error);
                return FALSE;
+       }
        for (i = 0; i < xrefs->len; i++) {
                FlatpakInstalledRef *xref = g_ptr_array_index (xrefs, i);
                g_autoptr(GError) error_local = NULL;
@@ -451,15 +490,19 @@ gs_flatpak_add_sources (GsFlatpak *self, GsAppList *list,
        xrefs = flatpak_installation_list_installed_refs (self->installation,
                                                          cancellable,
                                                          error);
-       if (xrefs == NULL)
+       if (xrefs == NULL) {
+               gs_plugin_flatpak_error_convert (error);
                return FALSE;
+       }
 
        /* get available remotes */
        xremotes = flatpak_installation_list_remotes (self->installation,
                                                      cancellable,
                                                      error);
-       if (xremotes == NULL)
+       if (xremotes == NULL) {
+               gs_plugin_flatpak_error_convert (error);
                return FALSE;
+       }
        for (i = 0; i < xremotes->len; i++) {
                FlatpakRemote *xremote = g_ptr_array_index (xremotes, i);
                g_autoptr(GsApp) app = NULL;
@@ -601,8 +644,10 @@ gs_flatpak_add_updates (GsFlatpak *self, GsAppList *list,
        xrefs = flatpak_installation_list_installed_refs (self->installation,
                                                          cancellable,
                                                          error);
-       if (xrefs == NULL)
+       if (xrefs == NULL) {
+               gs_plugin_flatpak_error_convert (error);
                return FALSE;
+       }
        for (i = 0; i < xrefs->len; i++) {
                FlatpakInstalledRef *xref = g_ptr_array_index (xrefs, i);
                const gchar *commit;
@@ -676,8 +721,10 @@ gs_flatpak_refresh (GsFlatpak *self,
        xrefs = flatpak_installation_list_installed_refs_for_update (self->installation,
                                                                     cancellable,
                                                                     error);
-       if (xrefs == NULL)
+       if (xrefs == NULL) {
+               gs_plugin_flatpak_error_convert (error);
                return FALSE;
+       }
        for (i = 0; i < xrefs->len; i++) {
                FlatpakInstalledRef *xref = g_ptr_array_index (xrefs, i);
                g_autoptr(GsApp) app = NULL;
@@ -698,8 +745,10 @@ gs_flatpak_refresh (GsFlatpak *self,
                                                     flatpak_ref_get_branch (FLATPAK_REF (xref)),
                                                     gs_flatpak_progress_cb, app,
                                                     cancellable, error);
-               if (xref2 == NULL)
+               if (xref2 == NULL) {
+                       gs_plugin_flatpak_error_convert (error);
                        return FALSE;
+               }
        }
 
        return TRUE;
@@ -727,8 +776,10 @@ gs_plugin_refine_item_origin_ui (GsFlatpak *self, GsApp *app,
        xremotes = flatpak_installation_list_remotes (self->installation,
                                                      cancellable,
                                                      error);
-       if (xremotes == NULL)
+       if (xremotes == NULL) {
+               gs_plugin_flatpak_error_convert (error);
                return FALSE;
+       }
        for (i = 0; i < xremotes->len; i++) {
                FlatpakRemote *xremote = g_ptr_array_index (xremotes, i);
                if (flatpak_remote_get_disabled (xremote))
@@ -762,8 +813,10 @@ gs_plugin_refine_item_origin_hostname (GsFlatpak *self, GsApp *app,
                                                           gs_app_get_origin (app),
                                                           cancellable,
                                                           error);
-       if (xremote == NULL)
+       if (xremote == NULL) {
+               gs_plugin_flatpak_error_convert (error);
                return FALSE;
+       }
        url = flatpak_remote_get_url (xremote);
        if (url == NULL) {
                g_set_error (error,
@@ -804,6 +857,7 @@ gs_refine_item_metadata (GsFlatpak *self, GsApp *app,
        /* parse the ref */
        xref = flatpak_ref_parse (gs_app_get_source_default (app), error);
        if (xref == NULL) {
+               gs_plugin_flatpak_error_convert (error);
                g_prefix_error (error, "failed to parse '%s': ",
                                gs_app_get_source_default (app));
                return FALSE;
@@ -839,8 +893,10 @@ refine_origin_from_installation (GsFlatpak *self,
        xremotes = flatpak_installation_list_remotes (installation,
                                                      cancellable,
                                                      error);
-       if (xremotes == NULL)
+       if (xremotes == NULL) {
+               gs_plugin_flatpak_error_convert (error);
                return FALSE;
+       }
        for (i = 0; i < xremotes->len; i++) {
                const gchar *remote_name;
                FlatpakRemote *xremote = g_ptr_array_index (xremotes, i);
@@ -883,10 +939,16 @@ gs_flatpak_get_installation_counterpart (GsFlatpak *self,
                                         GCancellable *cancellable,
                                         GError **error)
 {
+       FlatpakInstallation *installation;
        if (flatpak_installation_get_is_user (self->installation))
-               return flatpak_installation_new_system (cancellable, error);
-
-       return flatpak_installation_new_user (cancellable, error);
+               installation = flatpak_installation_new_system (cancellable, error);
+       else
+               installation = flatpak_installation_new_user (cancellable, error);
+       if (installation == NULL) {
+               gs_plugin_flatpak_error_convert (error);
+               return NULL;
+       }
+       return installation;
 }
 
 static gboolean
@@ -975,13 +1037,19 @@ gs_flatpak_app_matches_xref (GsFlatpak *self, GsApp *app, FlatpakRef *xref)
 static FlatpakRef *
 gs_flatpak_create_fake_ref (GsApp *app, GError **error)
 {
+       FlatpakRef *xref;
        g_autofree gchar *id = NULL;
        id = g_strdup_printf ("%s/%s/%s/%s",
                              gs_app_get_flatpak_kind_as_str (app),
                              gs_app_get_flatpak_name (app),
                              gs_app_get_flatpak_arch (app),
                              gs_app_get_flatpak_branch (app));
-       return flatpak_ref_parse (id, error);
+       xref = flatpak_ref_parse (id, error);
+       if (xref == NULL) {
+               gs_plugin_flatpak_error_convert (error);
+               return NULL;
+       }
+       return xref;
 }
 
 static gboolean
@@ -1008,8 +1076,10 @@ gs_plugin_refine_item_state (GsFlatpak *self,
        g_assert (ptask != NULL);
        xrefs = flatpak_installation_list_installed_refs (self->installation,
                                                          cancellable, error);
-       if (xrefs == NULL)
+       if (xrefs == NULL) {
+               gs_plugin_flatpak_error_convert (error);
                return FALSE;
+       }
        for (i = 0; i < xrefs->len; i++) {
                FlatpakInstalledRef *xref = g_ptr_array_index (xrefs, i);
 
@@ -1041,8 +1111,10 @@ gs_plugin_refine_item_state (GsFlatpak *self,
                        return FALSE;
                xrefs = flatpak_installation_list_installed_refs (installation,
                                                                  cancellable, error);
-               if (xrefs == NULL)
+               if (xrefs == NULL) {
+                       gs_plugin_flatpak_error_convert (error);
                        return FALSE;
+               }
                for (i = 0; i < xrefs->len; i++) {
                        FlatpakInstalledRef *xref = g_ptr_array_index (xrefs, i);
                        if (!gs_flatpak_app_matches_xref (self, app, FLATPAK_REF(xref)))
@@ -1101,15 +1173,21 @@ gs_flatpak_set_app_metadata (GsFlatpak *self,
        g_auto(GStrv) filesystems = NULL;
 
        kf = g_key_file_new ();
-       if (!g_key_file_load_from_data (kf, data, length, G_KEY_FILE_NONE, error))
+       if (!g_key_file_load_from_data (kf, data, length, G_KEY_FILE_NONE, error)) {
+               gs_plugin_flatpak_error_convert (error);
                return FALSE;
+       }
        name = g_key_file_get_string (kf, "Application", "name", error);
-       if (name == NULL)
+       if (name == NULL) {
+               gs_plugin_flatpak_error_convert (error);
                return FALSE;
+       }
        gs_app_set_flatpak_name (app, name);
        runtime = g_key_file_get_string (kf, "Application", "runtime", error);
-       if (runtime == NULL)
+       if (runtime == NULL) {
+               gs_plugin_flatpak_error_convert (error);
                return FALSE;
+       }
        g_debug ("runtime for %s is %s", name, runtime);
 
        /* we always get this, but it's a low bar... */
@@ -1194,8 +1272,10 @@ gs_plugin_refine_item_metadata (GsFlatpak *self,
                                                                        xref,
                                                                        cancellable,
                                                                        error);
-               if (data == NULL)
+               if (data == NULL) {
+                       gs_plugin_flatpak_error_convert (error);
                        return FALSE;
+               }
                str = g_bytes_get_data (data, &len);
        }
 
@@ -1219,6 +1299,8 @@ gs_flatpak_get_installed_ref (GsFlatpak *self,
                                                      gs_app_get_flatpak_branch (app),
                                                      cancellable,
                                                      error);
+       if (ref == NULL)
+               gs_plugin_flatpak_error_convert (error);
        return ref;
 }
 
@@ -1444,6 +1526,7 @@ gs_flatpak_launch (GsFlatpak *self,
                                          NULL,
                                          cancellable,
                                          error)) {
+               gs_plugin_flatpak_error_convert (error);
                return FALSE;
        }
        return TRUE;
@@ -1462,6 +1545,7 @@ gs_flatpak_app_remove_source (GsFlatpak *self,
                                                           gs_app_get_id (app),
                                                           cancellable, error);
        if (xremote == NULL) {
+               gs_plugin_flatpak_error_convert (error);
                g_prefix_error (error,
                                "flatpak source %s not found: ",
                                gs_app_get_id (app));
@@ -1626,6 +1710,7 @@ gs_flatpak_app_install (GsFlatpak *self,
                                                     cancellable, error);
        }
        if (xref == NULL) {
+               gs_plugin_flatpak_error_convert (error);
                gs_app_set_state_recover (app);
                return FALSE;
        }
@@ -1659,6 +1744,7 @@ gs_flatpak_update_app (GsFlatpak *self,
                                            gs_flatpak_progress_cb, app,
                                            cancellable, error);
        if (xref == NULL) {
+               gs_plugin_flatpak_error_convert (error);
                gs_app_set_state_recover (app);
                return FALSE;
        }
@@ -1690,6 +1776,7 @@ gs_flatpak_file_to_app_bundle (GsFlatpak *self,
        /* load bundle */
        xref_bundle = flatpak_bundle_ref_new (file, error);
        if (xref_bundle == NULL) {
+               gs_plugin_flatpak_error_convert (error);
                g_prefix_error (error, "error loading bundle: ");
                return FALSE;
        }
@@ -1739,11 +1826,15 @@ gs_flatpak_file_to_app_bundle (GsFlatpak *self,
                                                       0x100000, /* 1Mb */
                                                       cancellable,
                                                       error);
-               if (appstream == NULL)
+               if (appstream == NULL) {
+                       gs_plugin_flatpak_error_convert (error);
                        return FALSE;
+               }
                store = as_store_new ();
-               if (!as_store_from_bytes (store, appstream, cancellable, error))
+               if (!as_store_from_bytes (store, appstream, cancellable, error)) {
+                       gs_plugin_flatpak_error_convert (error);
                        return FALSE;
+               }
 
                /* allow peeking into this for debugging */
                if (g_getenv ("GS_FLATPAK_DEBUG_APPSTREAM") != NULL) {
@@ -1792,8 +1883,10 @@ gs_flatpak_file_to_app_bundle (GsFlatpak *self,
                g_autoptr(GdkPixbuf) pixbuf = NULL;
                stream_icon = g_memory_input_stream_new_from_bytes (icon_data);
                pixbuf = gdk_pixbuf_new_from_stream (stream_icon, cancellable, error);
-               if (pixbuf == NULL)
+               if (pixbuf == NULL) {
+                       gs_utils_error_convert_gdk_pixbuf (error);
                        return FALSE;
+               }
                gs_app_set_pixbuf (app, pixbuf);
        } else {
                g_autoptr(AsIcon) icon = NULL;
diff --git a/src/plugins/gs-plugin-appstream.c b/src/plugins/gs-plugin-appstream.c
index 2858e03..62ef4e0 100644
--- a/src/plugins/gs-plugin-appstream.c
+++ b/src/plugins/gs-plugin-appstream.c
@@ -244,8 +244,10 @@ gs_plugin_setup (GsPlugin *plugin, GCancellable *cancellable, GError **error)
                                     AS_STORE_LOAD_FLAG_APP_INSTALL,
                                     NULL,
                                     error);
-               if (!ret)
+               if (!ret) {
+                       gs_utils_error_convert_appstream (error);
                        return FALSE;
+               }
        }
        items = as_store_get_apps (priv->store);
        if (items->len == 0) {
diff --git a/src/plugins/gs-plugin-dpkg.c b/src/plugins/gs-plugin-dpkg.c
index bb82fcc..5d31bda 100644
--- a/src/plugins/gs-plugin-dpkg.c
+++ b/src/plugins/gs-plugin-dpkg.c
@@ -73,8 +73,10 @@ gs_plugin_file_to_app (GsPlugin *plugin,
        argv[3] = g_file_get_path (file);
        if (!g_spawn_sync (NULL, argv, NULL,
                           G_SPAWN_SEARCH_PATH | G_SPAWN_STDERR_TO_DEV_NULL,
-                          NULL, NULL, &output, NULL, NULL, error))
+                          NULL, NULL, &output, NULL, NULL, error)) {
+               gs_utils_error_convert_gio (error);
                return FALSE;
+       }
 
        /* parse output */
        tokens = g_strsplit (output, "\n", 0);
diff --git a/src/plugins/gs-plugin-dummy.c b/src/plugins/gs-plugin-dummy.c
index dfcb43f..8244ea9 100644
--- a/src/plugins/gs-plugin-dummy.c
+++ b/src/plugins/gs-plugin-dummy.c
@@ -115,6 +115,7 @@ gs_plugin_dummy_delay (GsPlugin *plugin,
        for (i = 0; i < 100; i++) {
                g_usleep (timeout_us);
                if (g_cancellable_set_error_if_cancelled (cancellable, error)) {
+                       gs_utils_error_convert_gio (error);
                        ret = FALSE;
                        break;
                }
diff --git a/src/plugins/gs-plugin-epiphany.c b/src/plugins/gs-plugin-epiphany.c
index ccd3502..da6ce23 100644
--- a/src/plugins/gs-plugin-epiphany.c
+++ b/src/plugins/gs-plugin-epiphany.c
@@ -198,8 +198,10 @@ gs_plugin_app_install (GsPlugin *plugin, GsApp *app,
                                         epi_desktop,
                                         NULL,
                                         error);
-       if (!ret)
+       if (!ret) {
+               gs_utils_error_convert_gio (error);
                return FALSE;
+       }
 
        /* update state */
        gs_app_set_state (app, AS_APP_STATE_INSTALLING);
@@ -234,8 +236,10 @@ gs_plugin_app_remove (GsPlugin *plugin, GsApp *app,
                                        gs_app_get_id (app),
                                        NULL);
        file_app = g_file_new_for_path (app_desktop);
-       if (!g_file_delete (file_app, NULL, error))
+       if (!g_file_delete (file_app, NULL, error)) {
+               gs_utils_error_convert_gio (error);
                return FALSE;
+       }
        gs_app_set_state (app, AS_APP_STATE_AVAILABLE);
        return TRUE;
 }
diff --git a/src/plugins/gs-plugin-fedora-distro-upgrades.c b/src/plugins/gs-plugin-fedora-distro-upgrades.c
index d89ee7d..7fe5280 100644
--- a/src/plugins/gs-plugin-fedora-distro-upgrades.c
+++ b/src/plugins/gs-plugin-fedora-distro-upgrades.c
@@ -342,8 +342,10 @@ gs_plugin_add_distro_upgrades (GsPlugin *plugin,
                return FALSE;
 
        /* get cached file */
-       if (!g_file_get_contents (priv->cachefn, &data, &len, error))
+       if (!g_file_get_contents (priv->cachefn, &data, &len, error)) {
+               gs_utils_error_convert_gio (error);
                return FALSE;
+       }
 
        /* parse data */
        settings = g_settings_new ("org.gnome.software");
diff --git a/src/plugins/gs-plugin-fwupd.c b/src/plugins/gs-plugin-fwupd.c
index 02bbc68..3bcce3a 100644
--- a/src/plugins/gs-plugin-fwupd.c
+++ b/src/plugins/gs-plugin-fwupd.c
@@ -49,6 +49,41 @@ struct GsPluginData {
        gchar                   *download_uri;
 };
 
+static void
+gs_plugin_fwupd_error_convert (GError **perror)
+{
+       GError *error = perror != NULL ? *perror : NULL;
+
+       /* not set */
+       if (error == NULL)
+               return;
+
+       /* custom to this plugin */
+       if (error->domain == FWUPD_ERROR) {
+               switch (error->code) {
+               case FWUPD_ERROR_ALREADY_PENDING:
+               case FWUPD_ERROR_INVALID_FILE:
+               case FWUPD_ERROR_NOT_SUPPORTED:
+                       error->code = GS_PLUGIN_ERROR_NOT_SUPPORTED;
+                       break;
+               case FWUPD_ERROR_AUTH_FAILED:
+                       error->code = GS_PLUGIN_ERROR_AUTH_INVALID;
+                       break;
+               case FWUPD_ERROR_SIGNATURE_INVALID:
+                       error->code = GS_PLUGIN_ERROR_NO_SECURITY;
+                       break;
+               default:
+                       error->code = GS_PLUGIN_ERROR_FAILED;
+                       break;
+               }
+       } else {
+               g_warning ("can't reliably fixup error from domain %s",
+                          g_quark_to_string (error->domain));
+               error->code = GS_PLUGIN_ERROR_FAILED;
+       }
+       error->domain = GS_PLUGIN_ERROR;
+}
+
 void
 gs_plugin_initialize (GsPlugin *plugin)
 {
@@ -186,8 +221,10 @@ gs_plugin_setup (GsPlugin *plugin, GCancellable *cancellable, GError **error)
        /* read config file */
        config = g_key_file_new ();
        if (!g_key_file_load_from_file (config, priv->config_fn,
-                                       G_KEY_FILE_NONE, error))
+                                       G_KEY_FILE_NONE, error)) {
+               gs_utils_error_convert_gio (error);
                return FALSE;
+       }
 
        /* get the download URI */
        priv->download_uri = g_key_file_get_string (config, "fwupd",
@@ -232,12 +269,16 @@ gs_plugin_setup (GsPlugin *plugin, GCancellable *cancellable, GError **error)
                                                         "firmware.xml.gz.asc",
                                                         GS_UTILS_CACHE_FLAG_WRITEABLE,
                                                         error);
-       if (priv->lvfs_sig_fn == NULL)
+       if (priv->lvfs_sig_fn == NULL) {
+               gs_utils_error_convert_gio (error);
                return FALSE;
+       }
        if (g_file_test (priv->lvfs_sig_fn, G_FILE_TEST_EXISTS)) {
                if (!g_file_get_contents (priv->lvfs_sig_fn,
-                                         &data, &len, error))
+                                         &data, &len, error)) {
+                       gs_utils_error_convert_gio (error);
                        return FALSE;
+               }
                priv->lvfs_sig_hash =
                        g_compute_checksum_for_data (G_CHECKSUM_SHA1, (guchar *) data, len);
        }
@@ -272,8 +313,10 @@ gs_plugin_fwupd_get_file_checksum (const gchar *filename,
        gsize len;
        g_autofree gchar *data = NULL;
 
-       if (!g_file_get_contents (filename, &data, &len, error))
+       if (!g_file_get_contents (filename, &data, &len, error)) {
+               gs_utils_error_convert_gio (error);
                return NULL;
+       }
        return g_compute_checksum_for_data (checksum_type, (const guchar *)data, len);
 }
 
@@ -544,10 +587,9 @@ gs_plugin_add_updates_historical (GsPlugin *plugin,
                                     FWUPD_ERROR,
                                     FWUPD_ERROR_NOT_FOUND))
                        return TRUE;
-               g_set_error_literal (error,
-                                    GS_PLUGIN_ERROR,
-                                    GS_PLUGIN_ERROR_FAILED,
-                                    error_local->message);
+               g_propagate_error (error, error_local);
+               error_local = NULL;
+               gs_plugin_fwupd_error_convert (error);
                return FALSE;
        }
 
@@ -576,10 +618,9 @@ gs_plugin_add_updates (GsPlugin *plugin,
                                     FWUPD_ERROR,
                                     FWUPD_ERROR_NOTHING_TO_DO))
                        return TRUE;
-               g_set_error_literal (error,
-                                    GS_PLUGIN_ERROR,
-                                    GS_PLUGIN_ERROR_FAILED,
-                                    error_local->message);
+               g_propagate_error (error, error_local);
+               error_local = NULL;
+               gs_plugin_fwupd_error_convert (error);
                return FALSE;
        }
 
@@ -685,9 +726,10 @@ gs_plugin_fwupd_check_lvfs_metadata (GsPlugin *plugin,
                                           cache_fn_data,
                                           priv->lvfs_sig_fn,
                                           cancellable,
-                                          error))
+                                          error)) {
+               gs_plugin_fwupd_error_convert (error);
                return FALSE;
-
+       }
        return TRUE;
 }
 
@@ -799,6 +841,7 @@ gs_plugin_fwupd_install (GsPlugin *plugin,
        if (!fwupd_client_install (priv->client, device_id,
                                   filename, install_flags,
                                   cancellable, error)) {
+               gs_plugin_fwupd_error_convert (error);
                gs_app_set_state_recover (app);
                return FALSE;
        }
@@ -843,11 +886,20 @@ gs_plugin_update_app (GsPlugin *plugin,
                                             "not enough data for fwupd unlock");
                        return FALSE;
                }
-               return fwupd_client_unlock (priv->client, device_id,
-                                           cancellable, error);
+               if (!fwupd_client_unlock (priv->client, device_id,
+                                         cancellable, error)) {
+                       gs_plugin_fwupd_error_convert (error);
+                       return FALSE;
+               }
+               return TRUE;
        }
 
-       return gs_plugin_fwupd_install (plugin, app, cancellable, error);
+       /* update means install */
+       if (!gs_plugin_fwupd_install (plugin, app, cancellable, error)) {
+               gs_plugin_fwupd_error_convert (error);
+               return FALSE;
+       }
+       return TRUE;
 }
 
 gboolean
@@ -885,8 +937,10 @@ gs_plugin_file_to_app (GsPlugin *plugin,
                                                  filename,
                                                  cancellable,
                                                  error);
-       if (results == NULL)
+       if (results == NULL) {
+               gs_plugin_fwupd_error_convert (error);
                return FALSE;
+       }
        for (i = 0; i < results->len; i++) {
                FwupdResult *res = g_ptr_array_index (results, i);
                g_autoptr(GsApp) app = NULL;
@@ -905,8 +959,10 @@ gs_plugin_file_to_app (GsPlugin *plugin,
                                        filename,
                                        cancellable,
                                        error);
-       if (res == NULL)
+       if (res == NULL) {
+               gs_plugin_fwupd_error_convert (error);
                return FALSE;
+       }
        app = gs_plugin_fwupd_new_app_from_results (plugin, res);
 
        /* we have no update view for local files */
diff --git a/src/plugins/gs-plugin-icons.c b/src/plugins/gs-plugin-icons.c
index 92225cb..2d73964 100644
--- a/src/plugins/gs-plugin-icons.c
+++ b/src/plugins/gs-plugin-icons.c
@@ -100,8 +100,10 @@ gs_plugin_icons_download (GsPlugin *plugin,
                                                      msg->response_body->length,
                                                      NULL);
        pixbuf = gdk_pixbuf_new_from_stream (stream, NULL, error);
-       if (pixbuf == NULL)
+       if (pixbuf == NULL) {
+               gs_utils_error_convert_gdk_pixbuf (error);
                return FALSE;
+       }
        if (gdk_pixbuf_get_height (pixbuf) == 64 &&
            gdk_pixbuf_get_width (pixbuf) == 64) {
                pixbuf_new = g_object_ref (pixbuf);
@@ -111,12 +113,17 @@ gs_plugin_icons_download (GsPlugin *plugin,
        }
 
        /* write file */
-       return gdk_pixbuf_save (pixbuf_new, filename, "png", error, NULL);
+       if (!gdk_pixbuf_save (pixbuf_new, filename, "png", error, NULL)) {
+               gs_utils_error_convert_gdk_pixbuf (error);
+               return FALSE;
+       }
+       return TRUE;
 }
 
 static GdkPixbuf *
 gs_plugin_icons_load_local (GsPlugin *plugin, AsIcon *icon, GError **error)
 {
+       GdkPixbuf *pixbuf;
        gint size;
        if (as_icon_get_filename (icon) == NULL) {
                g_set_error_literal (error,
@@ -126,8 +133,13 @@ gs_plugin_icons_load_local (GsPlugin *plugin, AsIcon *icon, GError **error)
                return NULL;
        }
        size = (gint) (64 * gs_plugin_get_scale (plugin));
-       return gdk_pixbuf_new_from_file_at_size (as_icon_get_filename (icon),
-                                                size, size, error);
+       pixbuf = gdk_pixbuf_new_from_file_at_size (as_icon_get_filename (icon),
+                                                  size, size, error);
+       if (pixbuf == NULL) {
+               gs_utils_error_convert_gdk_pixbuf (error);
+               return NULL;
+       }
+       return pixbuf;
 }
 
 static gchar *
@@ -215,6 +227,7 @@ static GdkPixbuf *
 gs_plugin_icons_load_stock (GsPlugin *plugin, AsIcon *icon, GError **error)
 {
        GsPluginData *priv = gs_plugin_get_data (plugin);
+       GdkPixbuf *pixbuf;
        gint size;
        g_autoptr(GMutexLocker) locker = g_mutex_locker_new (&priv->icon_theme_lock);
 
@@ -228,19 +241,27 @@ gs_plugin_icons_load_stock (GsPlugin *plugin, AsIcon *icon, GError **error)
        }
        gs_plugin_icons_add_theme_path (plugin, as_icon_get_prefix (icon));
        size = (gint) (64 * gs_plugin_get_scale (plugin));
-       return gtk_icon_theme_load_icon (priv->icon_theme,
-                                        as_icon_get_name (icon),
-                                        size,
-                                        GTK_ICON_LOOKUP_USE_BUILTIN |
-                                        GTK_ICON_LOOKUP_FORCE_SIZE,
-                                        error);
+       pixbuf = gtk_icon_theme_load_icon (priv->icon_theme,
+                                          as_icon_get_name (icon),
+                                          size,
+                                          GTK_ICON_LOOKUP_USE_BUILTIN |
+                                          GTK_ICON_LOOKUP_FORCE_SIZE,
+                                          error);
+       if (pixbuf == NULL) {
+               gs_utils_error_convert_gdk_pixbuf (error);
+               return NULL;
+       }
+       return pixbuf;
 }
 
 static GdkPixbuf *
 gs_plugin_icons_load_cached (GsPlugin *plugin, AsIcon *icon, GError **error)
 {
-       if (!as_icon_load (icon, AS_ICON_LOAD_FLAG_SEARCH_SIZE, error))
+       if (!as_icon_load (icon, AS_ICON_LOAD_FLAG_SEARCH_SIZE, error)) {
+               gs_utils_error_convert_gdk_pixbuf (error);
+               gs_utils_error_convert_appstream (error);
                return NULL;
+       }
        return g_object_ref (as_icon_get_pixbuf (icon));
 }
 
diff --git a/src/plugins/gs-plugin-odrs.c b/src/plugins/gs-plugin-odrs.c
index c30f8ec..9b6452b 100644
--- a/src/plugins/gs-plugin-odrs.c
+++ b/src/plugins/gs-plugin-odrs.c
@@ -129,8 +129,10 @@ gs_plugin_odrs_load_ratings (GsPlugin *plugin, const gchar *fn, GError **error)
 
        /* parse the data and find the success */
        json_parser = json_parser_new ();
-       if (!json_parser_load_from_file (json_parser, fn, error))
+       if (!json_parser_load_from_file (json_parser, fn, error)) {
+               gs_utils_error_convert_json_glib (error);
                return FALSE;
+       }
        json_root = json_parser_get_root (json_parser);
        if (json_root == NULL) {
                g_set_error_literal (error,
@@ -330,8 +332,10 @@ gs_plugin_odrs_parse_reviews (GsPlugin *plugin,
 
        /* parse the data and find the array or ratings */
        json_parser = json_parser_new ();
-       if (!json_parser_load_from_data (json_parser, data, data_len, error))
+       if (!json_parser_load_from_data (json_parser, data, data_len, error)) {
+               gs_utils_error_convert_json_glib (error);
                return NULL;
+       }
        json_root = json_parser_get_root (json_parser);
        if (json_root == NULL) {
                g_set_error_literal (error,
@@ -401,8 +405,10 @@ gs_plugin_odrs_parse_success (const gchar *data, gssize data_len, GError **error
 
        /* parse the data and find the success */
        json_parser = json_parser_new ();
-       if (!json_parser_load_from_data (json_parser, data, data_len, error))
+       if (!json_parser_load_from_data (json_parser, data, data_len, error)) {
+               gs_utils_error_convert_json_glib (error);
                return FALSE;
+       }
        json_root = json_parser_get_root (json_parser);
        if (json_root == NULL) {
                g_set_error_literal (error,
diff --git a/src/plugins/gs-plugin-ostree.c b/src/plugins/gs-plugin-ostree.c
index adf3d7f..ce8c7a4 100644
--- a/src/plugins/gs-plugin-ostree.c
+++ b/src/plugins/gs-plugin-ostree.c
@@ -72,8 +72,10 @@ gs_plugin_setup (GsPlugin *plugin, GCancellable *cancellable, GError **error)
 
        /* open */
        priv->ostree_repo = ostree_repo_new_default ();
-       if (!ostree_repo_open (priv->ostree_repo, cancellable, error))
+       if (!ostree_repo_open (priv->ostree_repo, cancellable, error)) {
+               gs_utils_error_convert_gio (error);
                return FALSE;
+       }
        return TRUE;
 }
 
@@ -97,8 +99,10 @@ gs_plugin_add_sources (GsPlugin *plugin,
 
                /* get info */
                if (!ostree_repo_remote_get_url (priv->ostree_repo,
-                                                names[i], &url, error))
+                                                names[i], &url, error)) {
+                       gs_utils_error_convert_gio (error);
                        return FALSE;
+               }
 
                /* create app */
                app = gs_app_new (names[i]);
diff --git a/src/plugins/gs-plugin-packagekit-refresh.c b/src/plugins/gs-plugin-packagekit-refresh.c
index 0192c54..6d442e9 100644
--- a/src/plugins/gs-plugin-packagekit-refresh.c
+++ b/src/plugins/gs-plugin-packagekit-refresh.c
@@ -146,7 +146,7 @@ gs_plugin_refresh (GsPlugin *plugin,
                                                         gs_plugin_packagekit_progress_cb, &data,
                                                         error);
                if (results2 == NULL) {
-                       gs_plugin_packagekit_convert_gerror (error);
+                       gs_plugin_packagekit_error_convert (error);
                        return FALSE;
                }
        }
diff --git a/src/plugins/gs-plugin-repos.c b/src/plugins/gs-plugin-repos.c
index d96f315..321f05c 100644
--- a/src/plugins/gs-plugin-repos.c
+++ b/src/plugins/gs-plugin-repos.c
@@ -80,8 +80,10 @@ gs_plugin_repos_setup (GsPlugin *plugin, GCancellable *cancellable, GError **err
 
        /* search all files */
        dir = g_dir_open (priv->reposdir, 0, error);
-       if (dir == NULL)
+       if (dir == NULL) {
+               gs_utils_error_convert_gio (error);
                return FALSE;
+       }
        while ((fn = g_dir_read_name (dir)) != NULL) {
                g_autofree gchar *filename = NULL;
                g_auto(GStrv) groups = NULL;
@@ -96,8 +98,10 @@ gs_plugin_repos_setup (GsPlugin *plugin, GCancellable *cancellable, GError **err
                filename = g_build_filename (priv->reposdir, fn, NULL);
                if (!g_key_file_load_from_file (kf, filename,
                                                G_KEY_FILE_NONE,
-                                               error))
+                                               error)) {
+                       gs_utils_error_convert_gio (error);
                        return FALSE;
+               }
 
                /* we can have multiple repos in one file */
                groups = g_key_file_get_groups (kf, NULL);
@@ -144,8 +148,10 @@ gs_plugin_setup (GsPlugin *plugin, GCancellable *cancellable, GError **error)
 
        /* watch for changes */
        priv->monitor = g_file_monitor_directory (file, G_FILE_MONITOR_NONE, cancellable, error);
-       if (priv->monitor == NULL)
+       if (priv->monitor == NULL) {
+               gs_utils_error_convert_gio (error);
                return FALSE;
+       }
        g_signal_connect (priv->monitor, "changed",
                          G_CALLBACK (gs_plugin_repos_changed_cb), plugin);
 
diff --git a/src/plugins/gs-plugin-shell-extensions.c b/src/plugins/gs-plugin-shell-extensions.c
index 5b22a9f..5484078 100644
--- a/src/plugins/gs-plugin-shell-extensions.c
+++ b/src/plugins/gs-plugin-shell-extensions.c
@@ -154,8 +154,10 @@ gs_plugin_shell_extensions_add_app (GsPlugin *plugin,
                                                 AS_MARKUP_CONVERT_FORMAT_SIMPLE,
                                                 NULL);
                        tmp2 = as_markup_convert_simple (tmp1, error);
-                       if (tmp2 == NULL)
+                       if (tmp2 == NULL) {
+                               gs_utils_error_convert_appstream (error);
                                return FALSE;
+                       }
                        gs_app_set_description (app, GS_APP_QUALITY_NORMAL, tmp2);
                        continue;
                }
@@ -280,8 +282,10 @@ gs_plugin_setup (GsPlugin *plugin, GCancellable *cancellable, GError **error)
                                                     "org.gnome.Shell.Extensions",
                                                     cancellable,
                                                     error);
-       if (priv->proxy == NULL)
+       if (priv->proxy == NULL) {
+               gs_utils_error_convert_gio (error);
                return FALSE;
+       }
        g_signal_connect (priv->proxy, "g-signal",
                          G_CALLBACK (gs_plugin_shell_extensions_changed_cb), plugin);
 
@@ -314,8 +318,10 @@ gs_plugin_add_installed (GsPlugin *plugin,
                                         -1,
                                         cancellable,
                                         error);
-       if (retval == NULL)
+       if (retval == NULL) {
+               gs_utils_error_convert_gio (error);
                return FALSE;
+       }
 
        /* parse each installed extension */
        g_variant_get (retval, "(a{sa{sv}})", &iter);
@@ -462,8 +468,10 @@ gs_plugin_shell_extensions_parse_app (GsPlugin *plugin,
        if (tmp != NULL) {
                g_autofree gchar *desc = NULL;
                desc = as_markup_import (tmp, AS_MARKUP_CONVERT_FORMAT_SIMPLE, error);
-               if (desc == NULL)
+               if (desc == NULL) {
+                       gs_utils_error_convert_appstream (error);
                        return NULL;
+               }
                as_app_set_description (app, NULL, desc);
        }
        tmp = json_object_get_string_member (json_app, "name");
@@ -561,8 +569,10 @@ gs_plugin_shell_extensions_parse_apps (GsPlugin *plugin,
 
        /* parse the data and find the success */
        json_parser = json_parser_new ();
-       if (!json_parser_load_from_data (json_parser, data, data_len, error))
+       if (!json_parser_load_from_data (json_parser, data, data_len, error)) {
+               gs_utils_error_convert_json_glib (error);
                return NULL;
+       }
        json_root = json_parser_get_root (json_parser);
        if (json_root == NULL) {
                g_set_error_literal (error,
@@ -796,6 +806,7 @@ gs_plugin_app_remove (GsPlugin *plugin,
                                         cancellable,
                                         error);
        if (retval == NULL) {
+               gs_utils_error_convert_gio (error);
                gs_app_set_state_recover (app);
                return FALSE;
        }
@@ -898,8 +909,10 @@ gs_plugin_launch (GsPlugin *plugin,
                                         -1,
                                         cancellable,
                                         error);
-       if (retval == NULL)
+       if (retval == NULL) {
+               gs_utils_error_convert_gio (error);
                return FALSE;
+       }
        return TRUE;
 }
 
diff --git a/src/plugins/gs-plugin-steam.c b/src/plugins/gs-plugin-steam.c
index fd7e74e..e64e3fc 100644
--- a/src/plugins/gs-plugin-steam.c
+++ b/src/plugins/gs-plugin-steam.c
@@ -135,8 +135,10 @@ gs_plugin_steam_parse_appinfo_file (const gchar *filename, GError **error)
        gboolean debug =  g_getenv ("GS_PLUGIN_STEAM_DEBUG") != NULL;
 
        /* load file */
-       if (!g_file_get_contents (filename, (gchar **) &data, &data_len, error))
+       if (!g_file_get_contents (filename, (gchar **) &data, &data_len, error)) {
+               gs_utils_error_convert_gio (error);
                return NULL;
+       }
 
        /* a GPtrArray of GHashTable */
        apps = g_ptr_array_new_with_free_func ((GDestroyNotify) g_hash_table_unref);
@@ -377,8 +379,10 @@ gs_plugin_steam_download_icon (GsPlugin *plugin,
        if (cache_fn == NULL)
                return FALSE;
        if (g_file_test (cache_fn, G_FILE_TEST_EXISTS)) {
-               if (!g_file_get_contents (cache_fn, &data, &data_len, error))
+               if (!g_file_get_contents (cache_fn, &data, &data_len, error)) {
+                       gs_utils_error_convert_gio (error);
                        return FALSE;
+               }
        } else {
                if (!gs_mkdir_parent (cache_fn, error))
                        return FALSE;
@@ -393,8 +397,10 @@ gs_plugin_steam_download_icon (GsPlugin *plugin,
 
        /* load the icon as large as possible */
        pb = gdk_pixbuf_new_from_file (cache_fn, error);
-       if (pb == NULL)
+       if (pb == NULL) {
+               gs_utils_error_convert_gdk_pixbuf (error);
                return FALSE;
+       }
 
        /* too small? */
        if (gdk_pixbuf_get_width (pb) < 48 ||
@@ -416,8 +422,10 @@ gs_plugin_steam_download_icon (GsPlugin *plugin,
                                                 error);
        if (cache_png == NULL)
                return FALSE;
-       if (!gdk_pixbuf_save (pb, cache_png, "png", error, NULL))
+       if (!gdk_pixbuf_save (pb, cache_png, "png", error, NULL)) {
+               gs_utils_error_convert_gdk_pixbuf (error);
                return FALSE;
+       }
 
        /* add an icon */
        icon = as_icon_new ();
@@ -594,8 +602,10 @@ gs_plugin_steam_update_store_app (GsPlugin *plugin,
        }
 
        /* get screenshots and descriptions */
-       if (!g_file_get_contents (cache_fn, &html, NULL, error))
+       if (!g_file_get_contents (cache_fn, &html, NULL, error)) {
+               gs_utils_error_convert_gio (error);
                return FALSE;
+       }
        if (!gs_plugin_steam_update_screenshots (item, html, error))
                return FALSE;
        if (!gs_plugin_steam_update_description (item, html, error))
@@ -683,11 +693,14 @@ gs_plugin_steam_refresh (GsPlugin *plugin,
                return FALSE;
 
        /* save new file */
-       return as_store_to_file (store, file,
-                                AS_NODE_TO_XML_FLAG_FORMAT_INDENT |
-                                AS_NODE_TO_XML_FLAG_FORMAT_MULTILINE,
-                                NULL,
-                                error);
+       if (!as_store_to_file (store, file,
+                              AS_NODE_TO_XML_FLAG_FORMAT_INDENT |
+                              AS_NODE_TO_XML_FLAG_FORMAT_MULTILINE,
+                              NULL, error)) {
+               gs_utils_error_convert_appstream (error);
+               return FALSE;
+       }
+       return TRUE;
 }
 
 gboolean
@@ -710,8 +723,10 @@ gs_plugin_steam_load_app_manifest (const gchar *fn, GError **error)
        g_auto(GStrv) lines = NULL;
 
        /* get file */
-       if (!g_file_get_contents (fn, &data, NULL, error))
+       if (!g_file_get_contents (fn, &data, NULL, error)) {
+               gs_utils_error_convert_gio (error);
                return NULL;
+       }
 
        /* parse each line */
        manifest = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
@@ -883,7 +898,11 @@ gs_plugin_app_install (GsPlugin *plugin, GsApp *app,
        gs_app_set_state (app, AS_APP_STATE_INSTALLING);
        gameid = gs_app_get_metadata_item (app, "X-Steam-GameID");
        cmdline = g_strdup_printf ("steam steam://install/%s", gameid);
-       return g_spawn_command_line_sync (cmdline, NULL, NULL, NULL, error);
+       if (!g_spawn_command_line_sync (cmdline, NULL, NULL, NULL, error)) {
+               gs_utils_error_convert_gio (error);
+               return FALSE;
+       }
+       return TRUE;
 }
 
 gboolean
@@ -902,7 +921,11 @@ gs_plugin_app_remove (GsPlugin *plugin, GsApp *app,
        gs_app_set_state (app, AS_APP_STATE_REMOVING);
        gameid = gs_app_get_metadata_item (app, "X-Steam-GameID");
        cmdline = g_strdup_printf ("steam steam://uninstall/%s", gameid);
-       return g_spawn_command_line_sync (cmdline, NULL, NULL, NULL, error);
+       if (!g_spawn_command_line_sync (cmdline, NULL, NULL, NULL, error)) {
+               gs_utils_error_convert_gio (error);
+               return FALSE;
+       }
+       return TRUE;
 }
 
 gboolean
@@ -920,7 +943,11 @@ gs_plugin_launch (GsPlugin *plugin, GsApp *app,
        /* this is async as steam is a different process: FIXME: use D-Bus */
        gameid = gs_app_get_metadata_item (app, "X-Steam-GameID");
        cmdline = g_strdup_printf ("steam steam://run/%s", gameid);
-       return g_spawn_command_line_sync (cmdline, NULL, NULL, NULL, error);
+       if (!g_spawn_command_line_sync (cmdline, NULL, NULL, NULL, error)) {
+               gs_utils_error_convert_gio (error);
+               return FALSE;
+       }
+       return TRUE;
 }
 
 gboolean
diff --git a/src/plugins/gs-plugin-systemd-updates.c b/src/plugins/gs-plugin-systemd-updates.c
index 8af162d..8b48b58 100644
--- a/src/plugins/gs-plugin-systemd-updates.c
+++ b/src/plugins/gs-plugin-systemd-updates.c
@@ -24,6 +24,8 @@
 #define I_KNOW_THE_PACKAGEKIT_GLIB2_API_IS_SUBJECT_TO_CHANGE
 #include <packagekit-glib2/packagekit.h>
 
+#include "packagekit-common.h"
+
 #include <gnome-software.h>
 
 /*
@@ -67,8 +69,10 @@ gs_plugin_setup (GsPlugin *plugin, GCancellable *cancellable, GError **error)
 {
        GsPluginData *priv = gs_plugin_get_data (plugin);
        priv->monitor = pk_offline_get_prepared_monitor (cancellable, error);
-       if (priv->monitor == NULL)
+       if (priv->monitor == NULL) {
+               gs_utils_error_convert_gio (error);
                return FALSE;
+       }
        g_signal_connect (priv->monitor, "changed",
                          G_CALLBACK (gs_plugin_systemd_updates_changed_cb),
                          plugin);
@@ -169,8 +173,12 @@ gs_plugin_update (GsPlugin *plugin,
        for (i = 0; i < gs_app_list_length (apps); i++) {
                GsApp *app = gs_app_list_index (apps, i);
                if (gs_plugin_systemd_updates_requires_trigger (app)) {
-                       return pk_offline_trigger (PK_OFFLINE_ACTION_REBOOT,
-                                                  cancellable, error);
+                       if (!pk_offline_trigger (PK_OFFLINE_ACTION_REBOOT,
+                                                cancellable, error)) {
+                               gs_plugin_packagekit_error_convert (error);
+                               return FALSE;
+                       }
+                       return TRUE;
                }
        }
        return TRUE;
diff --git a/src/plugins/gs-plugin-ubuntuone.c b/src/plugins/gs-plugin-ubuntuone.c
index c141947..9d69357 100644
--- a/src/plugins/gs-plugin-ubuntuone.c
+++ b/src/plugins/gs-plugin-ubuntuone.c
@@ -130,8 +130,10 @@ gs_plugin_auth_login (GsPlugin *plugin, GsAuth *auth,
        status_code = soup_session_send_message (gs_plugin_get_soup_session (plugin), msg);
 
        parser = json_parser_new ();
-       if (!json_parser_load_from_data (parser, msg->response_body->data, -1, error))
+       if (!json_parser_load_from_data (parser, msg->response_body->data, -1, error)) {
+               gs_utils_error_convert_json_glib (error);
                return FALSE;
+       }
        response_root = json_parser_get_root (parser);
 
        if (status_code != SOUP_STATUS_OK) {
diff --git a/src/plugins/packagekit-common.c b/src/plugins/packagekit-common.c
index 552698a..337db09 100644
--- a/src/plugins/packagekit-common.c
+++ b/src/plugins/packagekit-common.c
@@ -82,7 +82,7 @@ packagekit_status_enum_to_plugin_status (PkStatusEnum status)
 }
 
 gboolean
-gs_plugin_packagekit_convert_gerror (GError **error)
+gs_plugin_packagekit_error_convert (GError **error)
 {
        GError *error_tmp;
 
@@ -159,7 +159,7 @@ gs_plugin_packagekit_results_valid (PkResults *results, GError **error)
 
        /* method failed? */
        if (results == NULL) {
-               gs_plugin_packagekit_convert_gerror (error);
+               gs_plugin_packagekit_error_convert (error);
                return FALSE;
        }
 
diff --git a/src/plugins/packagekit-common.h b/src/plugins/packagekit-common.h
index 4293545..bed76bd 100644
--- a/src/plugins/packagekit-common.h
+++ b/src/plugins/packagekit-common.h
@@ -36,7 +36,7 @@ gboolean      gs_plugin_packagekit_add_results        (GsPlugin       *plugin,
                                                         GsAppList      *list,
                                                         PkResults      *results,
                                                         GError         **error);
-gboolean       gs_plugin_packagekit_convert_gerror     (GError         **error);
+gboolean       gs_plugin_packagekit_error_convert      (GError         **error);
 gboolean       gs_plugin_packagekit_results_valid      (PkResults      *results,
                                                         GError         **error);
 


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