mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-11-09 02:46:16 +01:00
gdbus-tool: avoid irrelevant note about arg types
gdbus-tool prints a hint about the expected arguments to a function call in case of errors. Unfortunately, it prints this message on all errors. I've seen this confuse users several times -- they go on tweaking the arguments trying to get the correct type, even though they had it correct in the first place. Let's limit the hint to the case where it was actually invalid arguments that triggered the problem. Also, adjust the code that prints the message so that it will also report on the case that no arguments were expected. We could possibly get closer to what we want by comparing the list of expected arguments with the parameter list, as it was parsed from the user, but that would involve composing the expected type. Let's keep this simple for now. https://bugzilla.gnome.org/show_bug.cgi?id=765710
This commit is contained in:
parent
5cea1c861d
commit
05060b6194
@ -1038,25 +1038,31 @@ handle_call (gint *argc,
|
||||
&error);
|
||||
if (result == NULL)
|
||||
{
|
||||
if (error)
|
||||
g_printerr (_("Error: %s\n"), error->message);
|
||||
|
||||
if (g_error_matches (error, G_DBUS_ERROR, G_DBUS_ERROR_INVALID_ARGS) && in_signature_types != NULL)
|
||||
{
|
||||
g_printerr (_("Error: %s\n"), error->message);
|
||||
g_error_free (error);
|
||||
}
|
||||
if (in_signature_types != NULL)
|
||||
{
|
||||
GString *s;
|
||||
s = g_string_new (NULL);
|
||||
for (n = 0; n < in_signature_types->len; n++)
|
||||
if (in_signature_types->len > 0)
|
||||
{
|
||||
GVariantType *type = in_signature_types->pdata[n];
|
||||
g_string_append_len (s,
|
||||
g_variant_type_peek_string (type),
|
||||
g_variant_type_get_string_length (type));
|
||||
GString *s;
|
||||
s = g_string_new (NULL);
|
||||
|
||||
for (n = 0; n < in_signature_types->len; n++)
|
||||
{
|
||||
GVariantType *type = in_signature_types->pdata[n];
|
||||
g_string_append_len (s,
|
||||
g_variant_type_peek_string (type),
|
||||
g_variant_type_get_string_length (type));
|
||||
}
|
||||
|
||||
g_printerr ("(According to introspection data, you need to pass '%s')\n", s->str);
|
||||
g_string_free (s, TRUE);
|
||||
}
|
||||
g_printerr ("(According to introspection data, you need to pass '%s')\n", s->str);
|
||||
g_string_free (s, TRUE);
|
||||
else
|
||||
g_printerr ("(According to introspection data, you need to pass no arguments)\n");
|
||||
}
|
||||
|
||||
g_error_free (error);
|
||||
goto out;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user