dbus: util: add missing try/catch block
Add try/catch block around ObjectMapper call failures.
Change-Id: I5a2a7a8c1049ea16cebe8b87a509bf5104e432ab
Signed-off-by: Patrick Venture <venture@google.com>
diff --git a/dbus/util.cpp b/dbus/util.cpp
index d39f176..080f39a 100644
--- a/dbus/util.cpp
+++ b/dbus/util.cpp
@@ -2,12 +2,15 @@
#include <cmath>
#include <iostream>
+#include <phosphor-logging/log.hpp>
#include <set>
using Property = std::string;
using Value = sdbusplus::message::variant<int64_t, double, std::string, bool>;
using PropertyMap = std::map<Property, Value>;
+using namespace phosphor::logging;
+
/* TODO(venture): Basically all phosphor apps need this, maybe it should be a
* part of sdbusplus. There is an old version in libmapper.
*/
@@ -23,14 +26,20 @@
mapper.append(path);
mapper.append(std::vector<std::string>({intf}));
- auto responseMsg = bus.call(mapper);
- if (responseMsg.is_method_error())
- {
- throw std::runtime_error("ObjectMapper Call Failure");
- }
-
std::map<std::string, std::vector<std::string>> response;
- responseMsg.read(response);
+
+ try
+ {
+ auto responseMsg = bus.call(mapper);
+
+ responseMsg.read(response);
+ }
+ catch (const sdbusplus::exception::SdBusError& ex)
+ {
+ log<level::ERR>("ObjectMapper call failure",
+ entry("WHAT=%s", ex.what()));
+ throw;
+ }
if (response.begin() == response.end())
{