From f69d25631d15c1c2a2179a79663d08d254f174c8 Mon Sep 17 00:00:00 2001 From: George Kiagiadakis Date: Mon, 25 Mar 2024 13:51:46 +0200 Subject: [PATCH] m-portal-permissionstore: improve the warnings printed due to remote errors Demote the NotFound error returned by Lookup(), as it seems common to be printed if the permission has not been configured. --- modules/module-portal-permissionstore.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/modules/module-portal-permissionstore.c b/modules/module-portal-permissionstore.c index 907da13e..ceb7cdb9 100644 --- a/modules/module-portal-permissionstore.c +++ b/modules/module-portal-permissionstore.c @@ -63,7 +63,16 @@ wp_portal_permissionstore_plugin_lookup (WpPortalPermissionStorePlugin *self, g_variant_new ("(ss)", table, id), NULL, G_DBUS_CALL_FLAGS_NONE, -1, NULL, &error); if (error) { - wp_warning_object (self, "Failed to call Lookup: %s", error->message); + g_autofree gchar *remote_error = g_dbus_error_get_remote_error (error); + g_dbus_error_strip_remote_error (error); + + /* NotFound is neither unexpected nor important, so log it as INFO */ + if (!g_strcmp0 (remote_error, "org.freedesktop.portal.Error.NotFound")) { + wp_info_object (self, "Lookup: %s (%s)", error->message, remote_error); + return NULL; + } + + wp_warning_object (self, "Lookup: %s (%s)", error->message, remote_error); return NULL; } @@ -90,8 +99,11 @@ wp_portal_permissionstore_plugin_set (WpPortalPermissionStorePlugin *self, DBUS_OBJECT_PATH, DBUS_INTERFACE_NAME, "Set", g_variant_new ("(sbs@a{sas}@v)", table, id, permissions, data), NULL, G_DBUS_CALL_FLAGS_NONE, -1, NULL, &error); - if (error) - wp_warning_object (self, "Failed to call Set: %s", error->message); + if (error) { + g_autofree gchar *remote_error = g_dbus_error_get_remote_error (error); + g_dbus_error_strip_remote_error (error); + wp_warning_object (self, "Set: %s (%s)", error->message, remote_error); + } } static void