extensions-tool: Log existing errors

In many cases we currently only indicate failure in the return value,
which is easily missed. Print some meaningful errors instead.

https://gitlab.gnome.org/GNOME/gnome-shell/issues/2391
This commit is contained in:
Florian Müllner 2020-03-14 11:00:49 +01:00
parent f5a170ce46
commit 23e382dd33
4 changed files with 31 additions and 7 deletions

View File

@ -46,13 +46,19 @@ show_extension_info (const char *uuid)
NULL,
&error);
if (response == NULL)
{
g_printerr (_("Failed to connect to GNOME Shell\n"));
return FALSE;
}
asv = g_variant_get_child_value (response, 0);
info = g_variant_dict_new (asv);
if (!g_variant_dict_contains (info, "uuid"))
{
g_printerr (_("Extension “%s” doesn't exist\n"), uuid);
return FALSE;
}
print_extension_info (info, DISPLAY_DETAILED);

View File

@ -60,7 +60,10 @@ list_extensions (ListFilterFlags filter, DisplayFormat format)
NULL,
&error);
if (response == NULL)
{
g_printerr (_("Failed to connect to GNOME Shell\n"));
return FALSE;
}
extensions = g_variant_get_child_value (response, 0);

View File

@ -47,17 +47,26 @@ launch_extension_prefs (const char *uuid)
NULL,
&error);
if (response == NULL)
{
g_printerr (_("Failed to connect to GNOME Shell"));
return FALSE;
}
asv = g_variant_get_child_value (response, 0);
info = g_variant_dict_new (asv);
if (!g_variant_dict_contains (info, "uuid"))
{
g_printerr (_("Extension “%s” doesn't exist\n"), uuid);
return FALSE;
}
g_variant_dict_lookup (info, "hasPrefs", "b", &has_prefs);
if (!has_prefs)
{
g_printerr (_("Extension “%s” doesn't have preferences\n"), uuid);
return FALSE;
}
g_dbus_proxy_call_sync (proxy,
"OpenExtensionPrefs",

View File

@ -45,10 +45,16 @@ uninstall_extension (const char *uuid)
NULL,
&error);
if (response == NULL)
{
g_printerr (_("Failed to connect to GNOME Shell"));
return FALSE;
}
g_variant_get (response, "(b)", &success);
if (!success)
g_printerr (_("Failed to uninstall “%s”\n"), uuid);
return success;
}