[glib] gdbus tool: print GVariant errors in context



commit ee5dab6bb5b84408d88fa7d3bb333311ab3fa263
Author: Ryan Lortie <desrt desrt ca>
Date:   Fri Nov 22 13:06:54 2013 -0500

    gdbus tool: print GVariant errors in context
    
    Use g_variant_parse_error_print_context() to format the error message
    from the GVariant parser.
    
    There is a slightly dubious interaction with the "parse me harder"
    functionality here.  We're probably going to have to deal with that
    separately.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=715028

 gio/gdbus-tool.c |   17 ++++++++++++++---
 1 files changed, 14 insertions(+), 3 deletions(-)
---
diff --git a/gio/gdbus-tool.c b/gio/gdbus-tool.c
index 2714dd7..2d4f6b1 100644
--- a/gio/gdbus-tool.c
+++ b/gio/gdbus-tool.c
@@ -671,18 +671,24 @@ handle_emit (gint        *argc,
                                &error);
       if (value == NULL)
         {
+          gchar *context;
+
+          context = g_variant_parse_error_print_context (error, (*argv)[n]);
           g_error_free (error);
           error = NULL;
           value = _g_variant_parse_me_harder (NULL, (*argv)[n], &error);
           if (value == NULL)
             {
+              /* Use the original non-"parse-me-harder" error */
               g_printerr (_("Error parsing parameter %d: %s\n"),
                           n,
-                          error->message);
+                          context);
               g_error_free (error);
+              g_free (context);
               g_variant_builder_clear (&builder);
               goto out;
             }
+          g_free (context);
         }
       g_variant_builder_add_value (&builder, value);
     }
@@ -973,6 +979,9 @@ handle_call (gint        *argc,
                                &error);
       if (value == NULL)
         {
+          gchar *context;
+
+          context = g_variant_parse_error_print_context (error, (*argv)[n]);
           g_error_free (error);
           error = NULL;
           value = _g_variant_parse_me_harder (type, (*argv)[n], &error);
@@ -984,19 +993,21 @@ handle_call (gint        *argc,
                   g_printerr (_("Error parsing parameter %d of type '%s': %s\n"),
                               n,
                               s,
-                              error->message);
+                              context);
                   g_free (s);
                 }
               else
                 {
                   g_printerr (_("Error parsing parameter %d: %s\n"),
                               n,
-                              error->message);
+                              context);
                 }
               g_error_free (error);
               g_variant_builder_clear (&builder);
+              g_free (context);
               goto out;
             }
+          g_free (context);
         }
       g_variant_builder_add_value (&builder, value);
     }


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