summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAdriana Kobylak <anoo@us.ibm.com>2018-06-06 15:33:22 -0500
committerAdriana Kobylak <anoo@us.ibm.com>2018-06-11 08:37:22 -0500
commit0049c98b6e4ee5fa5e78054a5a666b1e29598ab7 (patch)
tree349ff1929543ef5add2a7cd92bbc646cd70a88d5
parente5576bf2a145117c583c3ad05fec3a08aa90993d (diff)
downloadphosphor-dbus-monitor-0049c98b6e4ee5fa5e78054a5a666b1e29598ab7.zip
phosphor-dbus-monitor-0049c98b6e4ee5fa5e78054a5a666b1e29598ab7.tar.gz
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>
-rw-r--r--src/sdbusplus.hpp16
1 files changed, 15 insertions, 1 deletions
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 dbus
namespace monitoring
{
+using namespace phosphor::logging;
+using sdbusplus::exception::SdBusError;
+
/** @class SDBusPlus
* @brief DBus access delegate implementation for sdbusplus.
*/
@@ -72,7 +77,16 @@ class SDBusPlus
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;
}
OpenPOWER on IntegriCloud