bus: Add sd_bus_call() helper that ignores errors
This helper wraps the noreply case to make it trivial for callers to
ignore all errors associated with a call.
Change-Id: I9ddd639633694b315384f71e49f0760ada6de6ce
Signed-off-by: William A. Kennington III <wak@google.com>
diff --git a/sdbusplus/bus.hpp.in b/sdbusplus/bus.hpp.in
index 9252b73..9e7476b 100644
--- a/sdbusplus/bus.hpp.in
+++ b/sdbusplus/bus.hpp.in
@@ -270,6 +270,24 @@
}
}
+ /** @brief Perform a message call, ignoring the reply and any errors
+ * in the dbus stack.
+ *
+ * @param[in] m - The method_call message.
+ * @param[in] timeout_us - The timeout for the method call.
+ */
+ void call_noreply_noerror(message::message& m, uint64_t timeout_us = 0)
+ {
+ try
+ {
+ call_noreply(m, timeout_us);
+ }
+ catch (exception::SdBusError&)
+ {
+ // Intentionally ignoring these sd_bus errors
+ }
+ }
+
/** @brief Get the bus unique name. Ex: ":1.11".
*
* @return The bus unique name.