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 <a.soldatov@yadro.com>
Signed-off-by: Brad Bishop <bradleyb@fuzziesquirrel.com>
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 <experimental/tuple>
+#include <phosphor-logging/log.hpp>
namespace phosphor
{
@@ -13,6 +14,8 @@
namespace detail
{
+using namespace phosphor::logging;
+
/** @class CallDBusMethod
* @brief Provide explicit call forwarding to
* DBusInterface::callMethodNoReply.
@@ -27,8 +30,22 @@
const std::string& iface, const std::string& method,
MethodArgs&&... args)
{
- DBusInterface::callMethodNoReply(bus, path, iface, method,
- std::forward<MethodArgs>(args)...);
+ try
+ {
+ DBusInterface::callMethodNoReply(bus, path, iface, method,
+ std::forward<MethodArgs>(args)...);
+ }
+ catch (const sdbusplus::exception::SdBusError& e)
+ {
+ // clang-format off
+ log<level::ERR>("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 @@
CLEANFILES =
TESTS = $(check_PROGRAMS)
-XFAIL_TESTS = callbacktest
check_PROGRAMS += pathgentest
pathgentest_SOURCES = \