[gnome-software] trivial: Handle another error domain in flatpak
- From: Richard Hughes <rhughes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software] trivial: Handle another error domain in flatpak
- Date: Wed, 22 Feb 2017 19:35:47 +0000 (UTC)
commit e1b91deb411911b7210cf59c925db7c513b480e4
Author: Richard Hughes <richard hughsie com>
Date: Tue Feb 21 14:52:11 2017 +0000
trivial: Handle another error domain in flatpak
src/gs-utils.c | 38 ++++++++++++++++++++++++++++++++++++++
src/gs-utils.h | 1 +
src/plugins/gs-flatpak.c | 4 ++++
3 files changed, 43 insertions(+), 0 deletions(-)
---
diff --git a/src/gs-utils.c b/src/gs-utils.c
index 8d5df37..7f08ffe 100644
--- a/src/gs-utils.c
+++ b/src/gs-utils.c
@@ -699,6 +699,44 @@ gs_utils_error_convert_gio (GError **perror)
}
/**
+ * gs_utils_error_convert_gresolver:
+ * @perror: a pointer to a #GError, or %NULL
+ *
+ * Converts the #GResolverError to an error with a GsPluginError domain.
+ *
+ * Returns: %TRUE if the error was converted, or already correct
+ **/
+gboolean
+gs_utils_error_convert_gresolver (GError **perror)
+{
+ GError *error = perror != NULL ? *perror : NULL;
+
+ /* not set */
+ if (error == NULL)
+ return FALSE;
+ if (error->domain == GS_PLUGIN_ERROR)
+ return TRUE;
+ if (error->domain != G_RESOLVER_ERROR)
+ return FALSE;
+ switch (error->code) {
+ case G_RESOLVER_ERROR_INTERNAL:
+ error->code = GS_PLUGIN_ERROR_FAILED;
+ break;
+ case G_RESOLVER_ERROR_NOT_FOUND:
+ case G_RESOLVER_ERROR_TEMPORARY_FAILURE:
+ error->code = GS_PLUGIN_ERROR_DOWNLOAD_FAILED;
+ 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;
+ }
+ error->domain = GS_PLUGIN_ERROR;
+ return TRUE;
+}
+
+/**
* gs_utils_error_convert_gdk_pixbuf:
* @perror: a pointer to a #GError, or %NULL
*
diff --git a/src/gs-utils.h b/src/gs-utils.h
index 85cd6f2..a9cb783 100644
--- a/src/gs-utils.h
+++ b/src/gs-utils.h
@@ -74,6 +74,7 @@ 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_gresolver (GError **perror);
gboolean gs_utils_error_convert_gdbus (GError **perror);
gboolean gs_utils_error_convert_gdk_pixbuf(GError **perror);
gboolean gs_utils_error_convert_json_glib (GError **perror);
diff --git a/src/plugins/gs-flatpak.c b/src/plugins/gs-flatpak.c
index ef2aca8..ebe0a3a 100644
--- a/src/plugins/gs-flatpak.c
+++ b/src/plugins/gs-flatpak.c
@@ -70,6 +70,10 @@ gs_plugin_flatpak_error_convert (GError **perror)
if (gs_utils_error_convert_gdbus (perror))
return;
+ /* this are allowed for network ops */
+ if (gs_utils_error_convert_gresolver (perror))
+ return;
+
/* custom to this plugin */
if (error->domain == FLATPAK_ERROR) {
switch (error->code) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]