diff options
Diffstat (limited to 'src/software-dbus/sw-utils.c')
-rw-r--r-- | src/software-dbus/sw-utils.c | 35 |
1 files changed, 26 insertions, 9 deletions
diff --git a/src/software-dbus/sw-utils.c b/src/software-dbus/sw-utils.c index ca9722a..3cfa175 100644 --- a/src/software-dbus/sw-utils.c +++ b/src/software-dbus/sw-utils.c @@ -201,22 +201,39 @@ void sw_pkg_get_element_name(const SwPackage *pkg, char *elem_name, pkg->version, pkg->release, pkg->arch); } -short check_and_create_error_msg(PkResults *results, const char *custom_msg, - char *error_msg, const unsigned error_msg_len) +short check_and_create_error_msg(PkResults *results, GError *gerror, + const char *custom_msg, char *error_msg, const unsigned error_msg_len) { short ret = 0; PkError *error_code = NULL; - error_code = pk_results_get_error_code(results); - if (error_code) { - snprintf(error_msg, error_msg_len, - "%s: %s, %s", custom_msg, - pk_error_enum_to_string(pk_error_get_code(error_code)), - pk_error_get_details(error_code)); - g_object_unref(error_code); + if (results) { + error_code = pk_results_get_error_code(results); + if (error_code) { + snprintf(error_msg, error_msg_len, + "%s: %s, %s", custom_msg, + pk_error_enum_to_string(pk_error_get_code(error_code)), + pk_error_get_details(error_code)); + g_object_unref(error_code); + ret = 1; + goto done; + } + } + + if (gerror) { + snprintf(error_msg, error_msg_len, "%s: %s", custom_msg, + gerror->message); + ret = 1; + goto done; + } + + if (!results) { + snprintf(error_msg, error_msg_len, "%s: Nothing returned", custom_msg); ret = 1; + goto done; } +done: return ret; } |