[gnome-software/1910-software-fails-to-show-unhandled-error-from-fwupd] gs-shell: Enhance how notifies about failed actions on terminal



commit e7780b71ec719c24b8336cfdb58f571886917b52
Author: Milan Crha <mcrha redhat com>
Date:   Fri Sep 30 12:04:48 2022 +0200

    gs-shell: Enhance how notifies about failed actions on terminal
    
    Let every error being part of the verbose log, for easier debugging.
    Also change the "not handling error" message to include more details
    about the error, which could not be handled.
    
    Related to https://gitlab.gnome.org/GNOME/gnome-software/-/issues/1910

 src/gs-shell.c | 40 ++++++++++++++++++++++++++++++++++------
 1 file changed, 34 insertions(+), 6 deletions(-)
---
diff --git a/src/gs-shell.c b/src/gs-shell.c
index 2f8c25b81..cb730fca1 100644
--- a/src/gs-shell.c
+++ b/src/gs-shell.c
@@ -2070,9 +2070,27 @@ gs_shell_rescan_events (GsShell *shell)
        /* find the first active event and show it */
        event = gs_plugin_loader_get_event_default (shell->plugin_loader);
        if (event != NULL) {
+               GsPluginAction action = gs_plugin_event_get_action (event);
+               const GError *error = gs_plugin_event_get_error (event);
+               if (error != NULL &&
+                   !g_error_matches (error, GS_PLUGIN_ERROR, GS_PLUGIN_ERROR_CANCELLED) &&
+                   !g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) {
+                       if (error->domain == GS_PLUGIN_ERROR) {
+                               g_debug ("%sinteractive action '%s' failed with error '%s': %s",
+                                        gs_plugin_event_has_flag (event, GS_PLUGIN_EVENT_FLAG_INTERACTIVE) ? 
"" : "non-",
+                                        gs_plugin_action_to_string (action),
+                                        gs_plugin_error_to_string (error->code),
+                                        error->message);
+                       } else {
+                               g_debug ("%sinteractive action '%s' failed with error '%s::%d': %s",
+                                        gs_plugin_event_has_flag (event, GS_PLUGIN_EVENT_FLAG_INTERACTIVE) ? 
"" : "non-",
+                                        gs_plugin_action_to_string (action),
+                                        g_quark_to_string (error->domain),
+                                        error->code,
+                                        error->message);
+                       }
+               }
                if (!gs_shell_show_event (shell, event)) {
-                       GsPluginAction action = gs_plugin_event_get_action (event);
-                       const GError *error = gs_plugin_event_get_error (event);
                        if (error != NULL &&
                            !g_error_matches (error,
                                              GS_PLUGIN_ERROR,
@@ -2080,10 +2098,20 @@ gs_shell_rescan_events (GsShell *shell)
                            !g_error_matches (error,
                                              G_IO_ERROR,
                                              G_IO_ERROR_CANCELLED)) {
-                               g_warning ("not handling error %s for action %s: %s",
-                                          gs_plugin_error_to_string (error->code),
-                                          gs_plugin_action_to_string (action),
-                                          error->message);
+                               if (error->domain == GS_PLUGIN_ERROR) {
+                                       g_warning ("not handling %sinteractive error '%s' for action '%s': 
%s",
+                                                  gs_plugin_event_has_flag (event, 
GS_PLUGIN_EVENT_FLAG_INTERACTIVE) ? "" : "non-",
+                                                  gs_plugin_error_to_string (error->code),
+                                                  gs_plugin_action_to_string (action),
+                                                  error->message);
+                               } else {
+                                       g_warning ("not handling %sinteractive error '%s::%d' for action 
'%s': %s",
+                                                  gs_plugin_event_has_flag (event, 
GS_PLUGIN_EVENT_FLAG_INTERACTIVE) ? "" : "non-",
+                                                  g_quark_to_string (error->domain),
+                                                  error->code,
+                                                  gs_plugin_action_to_string (action),
+                                                  error->message);
+                               }
                        }
                        gs_plugin_event_add_flag (event, GS_PLUGIN_EVENT_FLAG_INVALID);
                        return;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]