From ec421f1ea1f78f40b93c476c7c4c948657e3bc52 Mon Sep 17 00:00:00 2001 From: Nikos Tsipinakis Date: Thu, 9 Apr 2020 19:38:27 +0200 Subject: [PATCH] Properly handle error conditions from dunstctl --- src/dbus.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/dbus.c b/src/dbus.c index ee44c04..6f288c6 100644 --- a/src/dbus.c +++ b/src/dbus.c @@ -583,11 +583,13 @@ GVariant *dbus_cb_dunst_Properties_Get(GDBusConnection *connection, { struct dunst_status status = dunst_status_get(); - if (STR_EQ(property_name, "running")) + if (STR_EQ(property_name, "running")) { return g_variant_new_boolean(status.running); - else - //TODO: is NULL as return value allowed? + } else { + LOG_W("Unknown property!\n"); + *error = g_error_new(G_DBUS_ERROR, G_DBUS_ERROR_UNKNOWN_PROPERTY, "Unknown property"); return NULL; + } } gboolean dbus_cb_dunst_Properties_Set(GDBusConnection *connection, @@ -604,11 +606,9 @@ gboolean dbus_cb_dunst_Properties_Set(GDBusConnection *connection, wake_up(); return true; } - - //FIXME: don't we have to return true on successful setting, but return false, if e.g. the parameter name is wrong? - //return true; - // so like this? + *error = g_error_new(G_DBUS_ERROR, G_DBUS_ERROR_UNKNOWN_PROPERTY, "Unknown property"); + return false; }