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>
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 @@
     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 @@
     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.