Handle SdBusError exceptions

sdbusplus can now throw exceptions, so while they aren't expected
the code should handle them.

Tested:  Create and delete error logs

Change-Id: I7cd596d628922ae3811fca227ae2ca123d8134d6
Signed-off-by: Matt Spinler <spinler@us.ibm.com>
diff --git a/manager.cpp b/manager.cpp
index 2503e93..7c53a08 100644
--- a/manager.cpp
+++ b/manager.cpp
@@ -25,6 +25,8 @@
 {
 
 namespace fs = std::experimental::filesystem;
+using namespace phosphor::logging;
+using sdbusplus::exception::SdBusError;
 
 Manager::Manager(sdbusplus::bus::bus& bus) :
     bus(bus),
@@ -48,19 +50,27 @@
 
 void Manager::createAll()
 {
-    auto objects = getManagedObjects(bus, LOGGING_BUSNAME, LOGGING_PATH);
-
-    for (const auto& object : objects)
+    try
     {
-        const auto& interfaces = object.second;
+        auto objects = getManagedObjects(bus, LOGGING_BUSNAME, LOGGING_PATH);
 
-        auto propertyMap = interfaces.find(LOGGING_IFACE);
-
-        if (propertyMap != interfaces.end())
+        for (const auto& object : objects)
         {
-            createWithRestore(object.first, interfaces);
+            const auto& interfaces = object.second;
+
+            auto propertyMap = interfaces.find(LOGGING_IFACE);
+
+            if (propertyMap != interfaces.end())
+            {
+                createWithRestore(object.first, interfaces);
+            }
         }
     }
+    catch (const SdBusError& e)
+    {
+        log<level::ERR>("sdbusplus error getting logging managed objects",
+                        entry("ERROR=%s", e.what()));
+    }
 }
 
 void Manager::createWithRestore(const std::string& objectPath,
@@ -190,50 +200,58 @@
 
     for (const auto& association : assocValue)
     {
-        if (std::get<forwardPos>(association) != "callout")
+        try
         {
-            continue;
-        }
+            if (std::get<forwardPos>(association) != "callout")
+            {
+                continue;
+            }
 
-        auto callout = std::get<endpointPos>(association);
+            auto callout = std::get<endpointPos>(association);
 
-        if (subtree.empty())
-        {
-            subtree = getSubtree(bus, "/", 0, ASSET_IFACE);
             if (subtree.empty())
             {
-                break;
+                subtree = getSubtree(bus, "/", 0, ASSET_IFACE);
+                if (subtree.empty())
+                {
+                    break;
+                }
             }
-        }
 
-        auto service = getService(callout, ASSET_IFACE, subtree);
-        if (service.empty())
+            auto service = getService(callout, ASSET_IFACE, subtree);
+            if (service.empty())
+            {
+                continue;
+            }
+
+            auto properties =
+                getAllProperties(bus, service, callout, ASSET_IFACE);
+            if (properties.empty())
+            {
+                continue;
+            }
+
+            auto calloutPath = getCalloutObjectPath(objectPath, calloutNum);
+
+            auto object = std::make_shared<Callout>(
+                bus, calloutPath, callout, calloutNum,
+                getLogTimestamp(interfaces), properties);
+
+            auto dir = getCalloutSaveDir(id);
+            if (!fs::exists(dir))
+            {
+                fs::create_directories(dir);
+            }
+            object->serialize(dir);
+
+            std::experimental::any anyObject = object;
+            addChildInterface(objectPath, InterfaceType::CALLOUT, anyObject);
+            calloutNum++;
+        }
+        catch (const SdBusError& e)
         {
-            continue;
+            log<level::ERR>("sdbusplus exception", entry("ERROR=%s", e.what()));
         }
-
-        auto properties = getAllProperties(bus, service, callout, ASSET_IFACE);
-        if (properties.empty())
-        {
-            continue;
-        }
-
-        auto calloutPath = getCalloutObjectPath(objectPath, calloutNum);
-
-        auto object =
-            std::make_shared<Callout>(bus, calloutPath, callout, calloutNum,
-                                      getLogTimestamp(interfaces), properties);
-
-        auto dir = getCalloutSaveDir(id);
-        if (!fs::exists(dir))
-        {
-            fs::create_directories(dir);
-        }
-        object->serialize(dir);
-
-        std::experimental::any anyObject = object;
-        addChildInterface(objectPath, InterfaceType::CALLOUT, anyObject);
-        calloutNum++;
     }
 }
 
@@ -256,7 +274,6 @@
         }
         catch (std::exception& e)
         {
-            using namespace phosphor::logging;
             log<level::ERR>("Invalid IBM logging callout save file. Deleting",
                             entry("FILE=%s", f.path().c_str()));
             fs::remove(f.path());