summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexander Soldatov <a.soldatov@yadro.com>2018-11-23 10:40:40 +0300
committerBrad Bishop <bradleyb@fuzziesquirrel.com>2018-12-06 09:09:52 -0500
commit12789e6c66cd21ba950c64b09ed1b4d2aae5f0d0 (patch)
tree30a15c06a12a8e64effce92b0fe055e49d92a9a0
parent78a5df906f563c99c451ea2355917ce414685a30 (diff)
downloadphosphor-dbus-monitor-12789e6c66cd21ba950c64b09ed1b4d2aae5f0d0.zip
phosphor-dbus-monitor-12789e6c66cd21ba950c64b09ed1b4d2aae5f0d0.tar.gz
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>
-rw-r--r--src/method.hpp21
-rw-r--r--src/test/Makefile.am1
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 <experimental/tuple>
+#include <phosphor-logging/log.hpp>
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<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 @@ BUILT_SOURCES =
CLEANFILES =
TESTS = $(check_PROGRAMS)
-XFAIL_TESTS = callbacktest
check_PROGRAMS += pathgentest
pathgentest_SOURCES = \
OpenPOWER on IntegriCloud