[packagekit] [PATCH] pkcon: check PK error in pk_console_resolve_package
Zhang Qiang
qiang.z.zhang at intel.com
Sun Dec 26 18:07:49 PST 2010
pk error should be checked first in pk_console_resolve_package, or pkcon
can't report correct error info, and pkcon can't catch the error occurs
in PK backend.
---
lib/packagekit-glib2/pk-console-shared.c | 9 +++++++++
1 files changed, 9 insertions(+), 0 deletions(-)
diff --git a/lib/packagekit-glib2/pk-console-shared.c b/lib/packagekit-glib2/pk-console-shared.c
index 6fd48c3..9291738 100644
--- a/lib/packagekit-glib2/pk-console-shared.c
+++ b/lib/packagekit-glib2/pk-console-shared.c
@@ -32,6 +32,7 @@
#include <packagekit-glib2/pk-results.h>
#include <packagekit-glib2/pk-package-id.h>
+#include "pk-error.h"
#include "pk-client-sync.h"
#include "pk-console-shared.h"
@@ -149,6 +150,7 @@ pk_console_resolve_package (PkClient *client, PkBitfield filter, const gchar *pa
guint i;
gchar *printable;
PkPackage *package;
+ PkError *error_code = NULL;
/* have we passed a complete package_id? */
valid = pk_package_id_check (package_name);
@@ -163,6 +165,13 @@ pk_console_resolve_package (PkClient *client, PkBitfield filter, const gchar *pa
if (results == NULL)
goto out;
+ /* check error code */
+ error_code = pk_results_get_error_code (results);
+ if (error_code != NULL) {
+ g_set_error (error, 1, 0, "\n%s", pk_error_get_details (error_code));
+ goto out;
+ }
+
/* get the packages returned */
array = pk_results_get_package_array (results);
if (array == NULL) {
--
1.7.2.2
More information about the PackageKit
mailing list