summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAdriana Kobylak <anoo@us.ibm.com>2018-07-10 12:55:51 -0500
committerAdriana Kobylak <anoo@us.ibm.com>2018-07-11 12:28:48 -0500
commit2ded5e1e3993913be34e8122f2b835468a2f9e91 (patch)
treeefb72772a3b89b3804cfa6ef07a496a313282775
parentcca7a7c8733a22f12d89dc0fd2d355f4fb9b4bb4 (diff)
downloadphosphor-dbus-monitor-2ded5e1e3993913be34e8122f2b835468a2f9e91.tar.gz
phosphor-dbus-monitor-2ded5e1e3993913be34e8122f2b835468a2f9e91.zip
sdbusplus: Improve error handling
Ignore exceptions from sdbusplus for objects that are queried as part of a property watch but are expected to be missing when the BMC starts up. Tested: The phosphor-dbus-monitor app does not core dump with the latest sdbusplus changes. Change-Id: I0f6a850f0e426478bd1ccacb910a44079b9c8a54 Signed-off-by: Adriana Kobylak <anoo@us.ibm.com>
-rw-r--r--src/sdbusplus.hpp22
1 files changed, 15 insertions, 7 deletions
diff --git a/src/sdbusplus.hpp b/src/sdbusplus.hpp
index f37f7de..0a8e715 100644
--- a/src/sdbusplus.hpp
+++ b/src/sdbusplus.hpp
@@ -102,15 +102,23 @@ class SDBusPlus
const std::string& interface)
{
std::vector<std::string> interfaces{interface};
-
- auto object = callMethodAndRead<GetObject>(
- MAPPER_BUSNAME, MAPPER_PATH, MAPPER_INTERFACE, "GetObject", path,
- interfaces);
-
std::string name;
- if (!object.empty())
+
+ try
{
- name = object.begin()->first;
+ auto object = callMethodAndRead<GetObject>(
+ MAPPER_BUSNAME, MAPPER_PATH, MAPPER_INTERFACE, "GetObject",
+ path, interfaces);
+
+ if (!object.empty())
+ {
+ name = object.begin()->first;
+ }
+ }
+ catch (const SdBusError& e)
+ {
+ // Empty responses are expected sometimes, and the calling
+ // code is set up to handle it.
}
return name;
}
OpenPOWER on IntegriCloud