propertywatch: Improve error handling

Handle exceptions from the sdbusplus method call API.

A number of method calls are made at application startup.  First the
mapper is queried and then host services directly to obtain initial
values for the property cache.

In either case a missing object is sometimes expected and tolerated
(in a logical sense) without issue.  Eat the new exceptions in these
scenarios and avoid a program crash.

Change-Id: Id79d28b2da997f3c545b86c21932e271e3df8bb3
Signed-off-by: Brad Bishop <bradleyb@fuzziesquirrel.com>
diff --git a/src/propertywatchimpl.hpp b/src/propertywatchimpl.hpp
index 003ee37..6500a15 100644
--- a/src/propertywatchimpl.hpp
+++ b/src/propertywatchimpl.hpp
@@ -47,11 +47,22 @@
 
         // Do a query to populate the cache.  Start with a mapper query.
         // The specific services are queried below.
-        const std::vector<std::string> queryInterfaces; // all interfaces
-        auto mapperResp =
-            DBusInterfaceType::template callMethodAndRead<GetObject>(
-                MAPPER_BUSNAME, MAPPER_PATH, MAPPER_INTERFACE, "GetObject",
-                path, queryInterfaces);
+        auto getObjectFromMapper = [](const auto& path) {
+            const std::vector<std::string> queryInterfaces; // all interfaces
+            try
+            {
+                return DBusInterfaceType::template callMethodAndRead<GetObject>(
+                    MAPPER_BUSNAME, MAPPER_PATH, MAPPER_INTERFACE, "GetObject",
+                    path, queryInterfaces);
+            }
+            catch (const sdbusplus::exception::SdBusError&)
+            {
+                // Paths in the configuration may not exist yet.  Prime those
+                // later, when/if InterfacesAdded occurs.
+                return GetObject();
+            }
+        };
+        auto mapperResp = getObjectFromMapper(path);
 
         for (const auto& i : interfaces)
         {
@@ -87,7 +98,16 @@
                 }
 
                 // Delegate type specific property updates to subclasses.
-                updateProperties(busName, path, interface);
+                try
+                {
+                    updateProperties(busName, path, interface);
+                }
+                catch (const sdbusplus::exception::SdBusError&)
+                {
+                    // If for some reason the path has gone away since
+                    // the mapper lookup we'll simply try again if/when
+                    // InterfacesAdded occurs the next time it shows up.
+                }
             }
         }
     }