[gnome-software] trivial: Don't warn if the error is already converted
- From: Richard Hughes <rhughes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software] trivial: Don't warn if the error is already converted
- Date: Fri, 9 Sep 2016 15:27:40 +0000 (UTC)
commit e81fcd7de6a088b59644f16a7d1cf2cd5c1554c3
Author: Richard Hughes <richard hughsie com>
Date: Fri Sep 9 16:26:43 2016 +0100
trivial: Don't warn if the error is already converted
src/gs-utils.c | 28 +++++++++++++++++++---------
src/gs-utils.h | 2 +-
src/plugins/gs-plugin-fwupd.c | 4 ++++
src/plugins/packagekit-common.c | 4 ++++
4 files changed, 28 insertions(+), 10 deletions(-)
---
diff --git a/src/gs-utils.c b/src/gs-utils.c
index e3d0892..bc31b15 100644
--- a/src/gs-utils.c
+++ b/src/gs-utils.c
@@ -554,7 +554,7 @@ gs_utils_error_strip_unique_id (GError *error)
*
* Converts the #GIOError to an error with a GsPluginError domain.
*
- * Returns: %TRUE if the error was converted
+ * Returns: %TRUE if the error was converted, or already correct
**/
gboolean
gs_utils_error_convert_gio (GError **perror)
@@ -564,11 +564,13 @@ gs_utils_error_convert_gio (GError **perror)
/* not set */
if (error == NULL)
return FALSE;
+ if (error->domain == GS_PLUGIN_ERROR)
+ return TRUE;
if (error->domain != G_IO_ERROR)
return FALSE;
- error->domain = GS_PLUGIN_ERROR;
switch (error->code) {
case G_IO_ERROR_FAILED:
+ case G_IO_ERROR_TIMED_OUT:
error->code = GS_PLUGIN_ERROR_FAILED;
break;
case G_IO_ERROR_NOT_SUPPORTED:
@@ -597,6 +599,7 @@ gs_utils_error_convert_gio (GError **perror)
error->code = GS_PLUGIN_ERROR_FAILED;
break;
}
+ error->domain = GS_PLUGIN_ERROR;
return TRUE;
}
@@ -606,7 +609,7 @@ gs_utils_error_convert_gio (GError **perror)
*
* Converts the #GdkPixbufError to an error with a GsPluginError domain.
*
- * Returns: %TRUE if the error was converted
+ * Returns: %TRUE if the error was converted, or already correct
**/
gboolean
gs_utils_error_convert_gdk_pixbuf (GError **perror)
@@ -616,9 +619,10 @@ gs_utils_error_convert_gdk_pixbuf (GError **perror)
/* not set */
if (error == NULL)
return FALSE;
+ if (error->domain == GS_PLUGIN_ERROR)
+ return TRUE;
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:
@@ -636,6 +640,7 @@ gs_utils_error_convert_gdk_pixbuf (GError **perror)
error->code = GS_PLUGIN_ERROR_FAILED;
break;
}
+ error->domain = GS_PLUGIN_ERROR;
return TRUE;
}
@@ -645,7 +650,7 @@ gs_utils_error_convert_gdk_pixbuf (GError **perror)
*
* Converts the #JsonParserError to an error with a GsPluginError domain.
*
- * Returns: %TRUE if the error was converted
+ * Returns: %TRUE if the error was converted, or already correct
**/
gboolean
gs_utils_error_convert_json_glib (GError **perror)
@@ -655,9 +660,10 @@ gs_utils_error_convert_json_glib (GError **perror)
/* not set */
if (error == NULL)
return FALSE;
+ if (error->domain == GS_PLUGIN_ERROR)
+ return TRUE;
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;
@@ -665,6 +671,7 @@ gs_utils_error_convert_json_glib (GError **perror)
error->code = GS_PLUGIN_ERROR_INVALID_FORMAT;
break;
}
+ error->domain = GS_PLUGIN_ERROR;
return TRUE;
}
@@ -675,16 +682,18 @@ gs_utils_error_convert_json_glib (GError **perror)
* Converts the various AppStream error types to an error with a GsPluginError
* domain.
*
- * Returns: %TRUE if the error was converted
+ * Returns: %TRUE if the error was converted, or already correct
**/
-void
+gboolean
gs_utils_error_convert_appstream (GError **perror)
{
GError *error = perror != NULL ? *perror : NULL;
/* not set */
if (error == NULL)
- return;
+ return FALSE;
+ if (error->domain == GS_PLUGIN_ERROR)
+ return TRUE;
/* custom to this plugin */
if (error->domain == AS_UTILS_ERROR) {
@@ -710,6 +719,7 @@ gs_utils_error_convert_appstream (GError **perror)
error->code = GS_PLUGIN_ERROR_FAILED;
}
error->domain = GS_PLUGIN_ERROR;
+ return TRUE;
}
/* vim: set noexpandtab: */
diff --git a/src/gs-utils.h b/src/gs-utils.h
index b41cf72..72d432a 100644
--- a/src/gs-utils.h
+++ b/src/gs-utils.h
@@ -76,7 +76,7 @@ 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);
+gboolean gs_utils_error_convert_appstream (GError **perror);
G_END_DECLS
diff --git a/src/plugins/gs-plugin-fwupd.c b/src/plugins/gs-plugin-fwupd.c
index 3bcce3a..8a3edf9 100644
--- a/src/plugins/gs-plugin-fwupd.c
+++ b/src/plugins/gs-plugin-fwupd.c
@@ -58,6 +58,10 @@ gs_plugin_fwupd_error_convert (GError **perror)
if (error == NULL)
return;
+ /* already correct */
+ if (error->domain == GS_PLUGIN_ERROR)
+ return;
+
/* custom to this plugin */
if (error->domain == FWUPD_ERROR) {
switch (error->code) {
diff --git a/src/plugins/packagekit-common.c b/src/plugins/packagekit-common.c
index 337db09..7644a04 100644
--- a/src/plugins/packagekit-common.c
+++ b/src/plugins/packagekit-common.c
@@ -92,6 +92,10 @@ gs_plugin_packagekit_error_convert (GError **error)
if (error_tmp == NULL)
return FALSE;
+ /* already correct */
+ if (error_tmp->domain == GS_PLUGIN_ERROR)
+ return TRUE;
+
/* get a local version */
if (error_tmp->domain != PK_CLIENT_ERROR)
return FALSE;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]