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/dbuspassive.cpp b/dbus/dbuspassive.cpp
index 375960f..c350ea3 100644
--- a/dbus/dbuspassive.cpp
+++ b/dbus/dbuspassive.cpp
@@ -50,6 +50,8 @@
     auto tempBus = sdbusplus::bus::new_default();
     /* service == busname */
     std::string path = GetSensorPath(type, id);
+
+    /* getService can except, should this be in the factory? */
     std::string service = _helper->getService(tempBus, sensorintf, path);
 
     struct SensorProperties settings;
diff --git a/dbus/dbuswrite.hpp b/dbus/dbuswrite.hpp
index 4c5bc29..577013d 100644
--- a/dbus/dbuswrite.hpp
+++ b/dbus/dbuswrite.hpp
@@ -33,6 +33,7 @@
         path(path)
     {
         auto tempBus = sdbusplus::bus::new_default();
+        // getService can except, does it make more sense to use a factory?
         connectionName = helper.getService(tempBus, pwmInterface, path);
     }
 
@@ -53,6 +54,7 @@
         path(path)
     {
         auto tempBus = sdbusplus::bus::new_default();
+        // getService can except, does it make more sense to use a factory?
         connectionName = helper.getService(tempBus, pwmInterface, path);
     }
 
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())
     {