Add sdbusplus exception handling

Tested: Verified that the phosphor-dbus-monitor does
not core dump with the latest sdbusplus changes to
support sdbusplus exceptions. Instead it logs the
"Failed to parse method response" error msg in the journal.

Resolves openbmc/openbmc#3213

Change-Id: I11347725364b5a43df6c0c1c377d65ce361a419c
Signed-off-by: Adriana Kobylak <anoo@us.ibm.com>
diff --git a/src/sdbusplus.hpp b/src/sdbusplus.hpp
index 1b54582..4339bad 100644
--- a/src/sdbusplus.hpp
+++ b/src/sdbusplus.hpp
@@ -1,6 +1,8 @@
 #pragma once
 
+#include <phosphor-logging/log.hpp>
 #include <sdbusplus/bus.hpp>
+#include <sdbusplus/exception.hpp>
 #include <sdbusplus/message.hpp>
 #include <sdbusplus/bus/match.hpp>
 #include "data_types.hpp"
@@ -14,6 +16,9 @@
 namespace monitoring
 {
 
+using namespace phosphor::logging;
+using sdbusplus::exception::SdBusError;
+
 /** @class SDBusPlus
  *  @brief DBus access delegate implementation for sdbusplus.
  */
@@ -72,7 +77,16 @@
         Ret resp;
         sdbusplus::message::message respMsg = callMethod<Args...>(
             busName, path, interface, method, std::forward<Args>(args)...);
-        respMsg.read(resp);
+        try
+        {
+            respMsg.read(resp);
+        }
+        catch (const SdBusError& e)
+        {
+            log<level::ERR>("Failed to parse method response",
+                            entry("ERROR=%s", e.what()),
+                            entry("REPLY_SIG=%s", respMsg.get_signature()));
+        }
         return resp;
     }