Fix: Exception handling during fetching of hostname

Handle the exception so that if there is a failure in getting
the hostname from hostnamed service, control should move ahead
and parse the routes and fetch the gateway etc.

Signed-off-by: Ratan Gupta <ratagupt@linux.vnet.ibm.com>
Change-Id: If2e38b854a9603b0c67e85d2b8e55f8718dd6c7e
diff --git a/system_configuration.cpp b/system_configuration.cpp
index c2d448c..268ea27 100644
--- a/system_configuration.cpp
+++ b/system_configuration.cpp
@@ -68,25 +68,27 @@
 
 std::string SystemConfiguration::getHostNameFromSystem() const
 {
-    std::variant<std::string> name;
-    auto method = bus.new_method_call(HOSTNAMED_SERVICE, HOSTNAMED_SERVICE_PATH,
-                                      PROPERTY_INTERFACE, METHOD_GET);
-
-    method.append(HOSTNAMED_INTERFACE, "Hostname");
-
-    auto reply = bus.call(method);
-
-    if (reply)
+    try
     {
+        std::variant<std::string> name;
+        auto method =
+            bus.new_method_call(HOSTNAMED_SERVICE, HOSTNAMED_SERVICE_PATH,
+                                PROPERTY_INTERFACE, METHOD_GET);
+
+        method.append(HOSTNAMED_INTERFACE, "Hostname");
+
+        auto reply = bus.call(method);
+
         reply.read(name);
+        return std::get<std::string>(name);
     }
-    else
+    catch (const sdbusplus::exception::SdBusError& ex)
     {
-        log<level::ERR>("Failed to get hostname");
-        report<InternalFailure>();
-        return "";
+        log<level::ERR>(
+            "Failed to get the hostname from systemd-hostnamed service",
+            entry("ERR=%s", ex.what()));
     }
-    return std::get<std::string>(name);
+    return "";
 }
 
 std::string SystemConfiguration::defaultGateway(std::string gateway)