From 12789e6c66cd21ba950c64b09ed1b4d2aae5f0d0 Mon Sep 17 00:00:00 2001 From: Alexander Soldatov Date: Fri, 23 Nov 2018 10:40:40 +0300 Subject: Exception processing added for CallDBusMethod::op. Patch adds exception processing for CallDBusMethod::op function. It prevents phosphor-dbus-monitor crashes, when calling service doesn't exist. Change-Id: Iac9be4c14a52fa9c12eb08dfec1f4dfd68e8cdfb Signed-off-by: Alexander Soldatov Signed-off-by: Brad Bishop --- src/method.hpp | 21 +++++++++++++++++++-- src/test/Makefile.am | 1 - 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/src/method.hpp b/src/method.hpp index 86326b6..f8f8f51 100644 --- a/src/method.hpp +++ b/src/method.hpp @@ -3,6 +3,7 @@ #include "callback.hpp" #include +#include namespace phosphor { @@ -13,6 +14,8 @@ namespace monitoring namespace detail { +using namespace phosphor::logging; + /** @class CallDBusMethod * @brief Provide explicit call forwarding to * DBusInterface::callMethodNoReply. @@ -27,8 +30,22 @@ struct CallDBusMethod const std::string& iface, const std::string& method, MethodArgs&&... args) { - DBusInterface::callMethodNoReply(bus, path, iface, method, - std::forward(args)...); + try + { + DBusInterface::callMethodNoReply(bus, path, iface, method, + std::forward(args)...); + } + catch (const sdbusplus::exception::SdBusError& e) + { + // clang-format off + log("Unable to call DBus method", + entry("BUS=%s", bus.c_str(), + "PATH=%s", path.c_str(), + "IFACE=%s", iface.c_str(), + "METHOD=%s", method.c_str(), + "ERROR=%s", e.what())); + // clang-format on + } } }; } // namespace detail diff --git a/src/test/Makefile.am b/src/test/Makefile.am index cbe9b82..3799890 100644 --- a/src/test/Makefile.am +++ b/src/test/Makefile.am @@ -12,7 +12,6 @@ BUILT_SOURCES = CLEANFILES = TESTS = $(check_PROGRAMS) -XFAIL_TESTS = callbacktest check_PROGRAMS += pathgentest pathgentest_SOURCES = \ -- cgit v1.2.1