From ee5dab6bb5b84408d88fa7d3bb333311ab3fa263 Mon Sep 17 00:00:00 2001 From: Ryan Lortie Date: Fri, 22 Nov 2013 13:06:54 -0500 Subject: [PATCH] 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 file changed, 14 insertions(+), 3 deletions(-) diff --git a/gio/gdbus-tool.c b/gio/gdbus-tool.c index 2714dd775..2d4f6b197 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); }