remove is_method_error call

An `is_method_error` is not appropriate after an sdbus `call` since
`call` will always throw an exception.  Remove the pointless call
and instead catch the exception.

Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
Change-Id: I6ece20bca5a99da3b7a6f3b6aa55b22842f3b422
diff --git a/src/ibm/hypervisor-network-mgr-src/hyp_network_manager.cpp b/src/ibm/hypervisor-network-mgr-src/hyp_network_manager.cpp
index 2539b6b..a3fe9c8 100644
--- a/src/ibm/hypervisor-network-mgr-src/hyp_network_manager.cpp
+++ b/src/ibm/hypervisor-network-mgr-src/hyp_network_manager.cpp
@@ -33,13 +33,7 @@
         "org.freedesktop.DBus.Properties", "Get");
     properties.append(interface);
     properties.append(kw);
-    auto result = bus.call(properties);
-
-    if (result.is_method_error())
-    {
-        throw std::runtime_error("Get api failed");
-    }
-    return result;
+    return bus.call(properties);
 }
 
 void HypNetworkMgr::setBIOSTableAttr(
@@ -109,12 +103,17 @@
 
         mapperCall.append(biosMgrObj, depth, interfaces);
 
-        auto mapperReply = bus.call(mapperCall);
-        if (mapperReply.is_method_error())
-        {
-            lg2::error("Error in mapper call");
-            elog<InternalFailure>();
-        }
+        auto mapperReply = [&]() {
+            try
+            {
+                return bus.call(mapperCall);
+            }
+            catch (const sdbusplus::exception::SdBusError& e)
+            {
+                lg2::error("Error in mapper call");
+                elog<InternalFailure>();
+            }
+        }();
 
         ObjectTree objectTree;
         mapperReply.read(objectTree);
diff --git a/src/ibm/hypervisor-network-mgr-src/hyp_sys_config.cpp b/src/ibm/hypervisor-network-mgr-src/hyp_sys_config.cpp
index 853ee11..194bb19 100644
--- a/src/ibm/hypervisor-network-mgr-src/hyp_sys_config.cpp
+++ b/src/ibm/hypervisor-network-mgr-src/hyp_sys_config.cpp
@@ -75,12 +75,7 @@
                                           BIOS_MGR_INTF, "SetAttribute");
     properties.append("vmi_hostname");
     properties.append(std::variant<std::string>(name));
-    auto result = bus.call(properties);
-
-    if (result.is_method_error())
-    {
-        throw std::runtime_error("Set attribute api failed");
-    }
+    bus.call(properties);
 }
 
 } // namespace network
diff --git a/src/inventory_mac.cpp b/src/inventory_mac.cpp
index 8d38c37..67e8dff 100644
--- a/src/inventory_mac.cpp
+++ b/src/inventory_mac.cpp
@@ -91,12 +91,17 @@
 
     mapperCall.append(invRoot, depth, interfaces);
 
-    auto mapperReply = bus.call(mapperCall);
-    if (mapperReply.is_method_error())
-    {
-        lg2::error("Error in mapper call");
-        elog<InternalFailure>();
-    }
+    auto mapperReply = [&]() {
+        try
+        {
+            return bus.call(mapperCall);
+        }
+        catch (const sdbusplus::exception::SdBusError& e)
+        {
+            lg2::error("Error in mapper call");
+            elog<InternalFailure>();
+        }
+    }();
 
     ObjectTree objectTree;
     mapperReply.read(objectTree);
@@ -145,14 +150,19 @@
 
     method.append(invNetworkIntf, "MACAddress");
 
-    auto reply = bus.call(method);
-    if (reply.is_method_error())
-    {
-        lg2::error(
-            "Failed to get MACAddress for path {DBUS_PATH} interface {DBUS_INTF}",
-            "DBUS_PATH", objPath, "DBUS_INTF", invNetworkIntf);
-        elog<InternalFailure>();
-    }
+    auto reply = [&]() {
+        try
+        {
+            return bus.call(method);
+        }
+        catch (const sdbusplus::exception::SdBusError& e)
+        {
+            lg2::error(
+                "Failed to get MACAddress for path {DBUS_PATH} interface {DBUS_INTF}",
+                "DBUS_PATH", objPath, "DBUS_INTF", invNetworkIntf);
+            elog<InternalFailure>();
+        }
+    }();
 
     std::variant<std::string> value;
     reply.read(value);