[gnome-software/wip/temp/ubuntu-xenial-rebased-corrected: 56/331] Better error reporting
- From: William Hua <williamhua src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software/wip/temp/ubuntu-xenial-rebased-corrected: 56/331] Better error reporting
- Date: Wed, 4 May 2016 14:03:13 +0000 (UTC)
commit 288679aee41af176359806649487d879b3f5b9d6
Author: Robert Ancell <robert ancell canonical com>
Date: Tue Jan 26 13:51:52 2016 +1300
Better error reporting
src/plugins/gs-plugin-snappy.c | 18 ++++++++++++++----
1 files changed, 14 insertions(+), 4 deletions(-)
---
diff --git a/src/plugins/gs-plugin-snappy.c b/src/plugins/gs-plugin-snappy.c
index 3fe008b..ee16097 100644
--- a/src/plugins/gs-plugin-snappy.c
+++ b/src/plugins/gs-plugin-snappy.c
@@ -235,10 +235,20 @@ get_apps (GsPlugin *plugin, GList **list, AppFilterFunc filter_func, gpointer us
}
parser = json_parser_new ();
- if (!json_parser_load_from_data (parser, response, -1, NULL))
- return 1;
- if (!JSON_NODE_HOLDS_OBJECT (json_parser_get_root (parser)))
- return 1;
+ if (!json_parser_load_from_data (parser, response, -1, &sub_error)) {
+ g_set_error (error,
+ GS_PLUGIN_ERROR,
+ GS_PLUGIN_ERROR_FAILED,
+ "Unable to parse snapd response: %s", sub_error->message);
+ return FALSE;
+ }
+ if (!JSON_NODE_HOLDS_OBJECT (json_parser_get_root (parser))) {
+ g_set_error_literal (error,
+ GS_PLUGIN_ERROR,
+ GS_PLUGIN_ERROR_FAILED,
+ "snapd response does is not a valid JSON object");
+ return FALSE;
+ }
root = json_node_get_object (json_parser_get_root (parser));
result = json_object_get_object_member (root, "result");
packages = json_object_get_object_member (result, "packages");
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]