summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatt Spinler <spinler@us.ibm.com>2018-09-24 11:31:44 -0500
committerMatt Spinler <spinler@us.ibm.com>2018-09-24 11:31:44 -0500
commit911229275728128ec0f6ac044079c61bdd7aeb01 (patch)
tree1e00996a606480619d7158fea2067de15f0776da
parente77b8345d88c90288e4846c5da200187bed59d00 (diff)
downloadphosphor-led-manager-911229275728128ec0f6ac044079c61bdd7aeb01.tar.gz
phosphor-led-manager-911229275728128ec0f6ac044079c61bdd7aeb01.zip
fault-monitor: Catch GetSubTree exceptions
The C++ implementation of the mapper will throw an exception if the passed in interface was not found on any paths, which is expected to happen when fru-fault-monitor checks for error logs on startup and there aren't any. Catch that exception and just continue on the path of there being no error logs. Note this is made slightly more complicated by the fact that the default constructor for sdbusplus::message is deleted, so one cannot just do: sdbusplus::message reply; try { auto method = bus.new_method_call(...); reply = bus.call(method); } ... reply.read(...); Change-Id: Ic15c7112cbfe0f3df974748f90828f12255ec29a Signed-off-by: Matt Spinler <spinler@us.ibm.com>
-rw-r--r--fault-monitor/fru-fault-monitor.cpp49
1 files changed, 30 insertions, 19 deletions
diff --git a/fault-monitor/fru-fault-monitor.cpp b/fault-monitor/fru-fault-monitor.cpp
index 8f5f8fa..aecb481 100644
--- a/fault-monitor/fru-fault-monitor.cpp
+++ b/fault-monitor/fru-fault-monitor.cpp
@@ -217,7 +217,7 @@ void Add::created(sdbusplus::message::message& msg)
return;
}
-void Add::processExistingCallouts(sdbusplus::bus::bus& bus)
+void getLoggingSubTree(sdbusplus::bus::bus& bus, MapperResponseType& subtree)
{
auto depth = 0;
auto mapperCall = bus.new_method_call(MAPPER_BUSNAME,
@@ -228,30 +228,41 @@ void Add::processExistingCallouts(sdbusplus::bus::bus& bus)
mapperCall.append(depth);
mapperCall.append(std::vector<Interface>({LOG_IFACE}));
- auto mapperResponseMsg = bus.call(mapperCall);
- if (mapperResponseMsg.is_method_error())
- {
- using namespace xyz::openbmc_project::Led::Mapper;
- report<MethodErr>(
- MethodError::METHOD_NAME("GetSubTree"),
- MethodError::PATH(MAPPER_OBJ_PATH),
- MethodError::INTERFACE(
- OBJMGR_IFACE));
- return;
- }
-
- MapperResponseType mapperResponse;
try
{
- mapperResponseMsg.read(mapperResponse);
+ auto mapperResponseMsg = bus.call(mapperCall);
+ if (mapperResponseMsg.is_method_error())
+ {
+ using namespace xyz::openbmc_project::Led::Mapper;
+ report<MethodErr>(
+ MethodError::METHOD_NAME("GetSubTree"),
+ MethodError::PATH(MAPPER_OBJ_PATH),
+ MethodError::INTERFACE(OBJMGR_IFACE));
+ return;
+ }
+
+ try
+ {
+ mapperResponseMsg.read(subtree);
+ }
+ catch (const sdbusplus::exception::SdBusError& e)
+ {
+ log<level::ERR>("Failed to parse existing callouts subtree message",
+ entry("ERROR=%s", e.what()),
+ entry("REPLY_SIG=%s", mapperResponseMsg.get_signature()));
+ }
}
catch (const sdbusplus::exception::SdBusError& e)
{
- log<level::ERR>("Failed to parse existing callouts subtree message",
- entry("ERROR=%s", e.what()),
- entry("REPLY_SIG=%s", mapperResponseMsg.get_signature()));
- return;
+ // Just means no log entries at the moment
}
+}
+
+void Add::processExistingCallouts(sdbusplus::bus::bus& bus)
+{
+ MapperResponseType mapperResponse;
+
+ getLoggingSubTree(bus, mapperResponse);
if (mapperResponse.empty())
{
//No errors to process.
OpenPOWER on IntegriCloud