From e44c445262c4b1e00a342e0f5c8bd289c10aa207 Mon Sep 17 00:00:00 2001 From: Marc Di Luzio Date: Thu, 21 Feb 2019 18:07:56 +0000 Subject: [PATCH] Use the actual dbus error when failing in the client This helps greatly when identifying what went wrong --- lib/client_impl.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/lib/client_impl.c b/lib/client_impl.c index 4c23278..1627596 100644 --- a/lib/client_impl.c +++ b/lib/client_impl.c @@ -47,6 +47,8 @@ static int gamemode_request(const char *function, int arg) { sd_bus_message *msg = NULL; sd_bus *bus = NULL; + sd_bus_error err; + memset(&err, 0, sizeof(err)); int result = -1; @@ -64,7 +66,7 @@ static int gamemode_request(const char *function, int arg) "/com/feralinteractive/GameMode", "com.feralinteractive.GameMode", function, - NULL, + &err, &msg, arg ? "ii" : "i", getpid(), @@ -72,7 +74,13 @@ static int gamemode_request(const char *function, int arg) if (ret < 0) { snprintf(error_string, sizeof(error_string), - "Could not call method on bus: %s", + "Could not call method %s on com.feralinteractive.GameMode\n" + "\t%s\n" + "\t%s\n" + "\t%s\n", + function, + err.name, + err.message, strerror(-ret)); } else { // Read the reply