[gnome-software: 36/38] gs-plugin-job-list-installed-apps: Tweak error handling
- From: Philip Withnall <pwithnall src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software: 36/38] gs-plugin-job-list-installed-apps: Tweak error handling
- Date: Thu, 3 Mar 2022 16:39:54 +0000 (UTC)
commit a6c00c5bd44c8935c0fdb399244a3595acba9adf
Author: Philip Withnall <pwithnall endlessos org>
Date: Thu Mar 3 14:12:01 2022 +0000
gs-plugin-job-list-installed-apps: Tweak error handling
This prints a debug message if additional parallel operations fail, as
well as propagating the first error (as before). This should make
failures a bit easier to debug. It also makes the parallel code more
akin to other parallel code I’ve added recently.
Signed-off-by: Philip Withnall <pwithnall endlessos org>
Helps: #1472
lib/gs-plugin-job-list-installed-apps.c | 37 ++++++++++++++++++---------------
1 file changed, 20 insertions(+), 17 deletions(-)
---
diff --git a/lib/gs-plugin-job-list-installed-apps.c b/lib/gs-plugin-job-list-installed-apps.c
index f39bf287b..24789e8ed 100644
--- a/lib/gs-plugin-job-list-installed-apps.c
+++ b/lib/gs-plugin-job-list-installed-apps.c
@@ -242,7 +242,8 @@ sorted_truncation_again (GsPluginJobListInstalledApps *self,
static void plugin_list_installed_apps_cb (GObject *source_object,
GAsyncResult *result,
gpointer user_data);
-static void finish_op (GTask *task);
+static void finish_op (GTask *task,
+ GError *error);
static void refine_cb (GObject *source_object,
GAsyncResult *result,
gpointer user_data);
@@ -291,13 +292,15 @@ gs_plugin_job_list_installed_apps_run_async (GsPluginJob *job,
/* some functions are really required for proper operation */
if (!anything_ran) {
- g_set_error_literal (&self->saved_error,
+ g_autoptr(GError) local_error = NULL;
+ g_set_error_literal (&local_error,
GS_PLUGIN_ERROR,
GS_PLUGIN_ERROR_NOT_SUPPORTED,
"no plugin could handle listing installed apps");
+ finish_op (task, g_steal_pointer (&local_error));
+ } else {
+ finish_op (task, NULL);
}
-
- finish_op (task);
}
static void
@@ -315,26 +318,27 @@ plugin_list_installed_apps_cb (GObject *source_object,
plugin_apps = plugin_class->list_installed_apps_finish (plugin, result, &local_error);
gs_plugin_status_update (plugin, NULL, GS_PLUGIN_STATUS_FINISHED);
- if (plugin_apps != NULL) {
+ if (plugin_apps != NULL)
gs_app_list_add_list (self->merged_list, plugin_apps);
- } else {
- gs_utils_error_convert_gio (&local_error);
- if (self->saved_error == NULL)
- self->saved_error = g_steal_pointer (&local_error);
- }
-
- finish_op (task);
+ finish_op (task, g_steal_pointer (&local_error));
}
+/* @error is (transfer full) if non-%NULL */
static void
-finish_op (GTask *task)
+finish_op (GTask *task,
+ GError *error)
{
GsPluginJobListInstalledApps *self = g_task_get_source_object (task);
GCancellable *cancellable = g_task_get_cancellable (task);
GsPluginLoader *plugin_loader = g_task_get_task_data (task);
g_autoptr(GsAppList) merged_list = NULL;
- g_autoptr(GError) saved_error = NULL;
+ g_autoptr(GError) error_owned = g_steal_pointer (&error);
+
+ if (error_owned != NULL && self->saved_error == NULL)
+ self->saved_error = g_steal_pointer (&error_owned);
+ else if (error_owned != NULL)
+ g_debug ("Additional error while listing installed apps: %s", error_owned->message);
g_assert (self->n_pending_ops > 0);
self->n_pending_ops--;
@@ -344,10 +348,9 @@ finish_op (GTask *task)
/* Get the results of the parallel ops. */
merged_list = g_steal_pointer (&self->merged_list);
- saved_error = g_steal_pointer (&self->saved_error);
- if (saved_error != NULL) {
- g_task_return_error (task, g_steal_pointer (&saved_error));
+ if (self->saved_error != NULL) {
+ g_task_return_error (task, g_steal_pointer (&self->saved_error));
return;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]