Use the actual dbus error when failing in the client

This helps greatly when identifying what went wrong
This commit is contained in:
Marc Di Luzio 2019-02-21 18:07:56 +00:00
parent 3c28e84700
commit e44c445262

View File

@ -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