Handle D-Bus exceptions

Remove the usage of is_method_error()[1]
Also, add try-catch to handle D-Bus exceptions around mapper call.

[1]https://gerrit.openbmc-project.xyz/c/openbmc/sdbusplus/+/14010

Signed-off-by: George Liu <liuxiwei@inspur.com>
Change-Id: I042e86676950aa25d646ff597ac55500abe44ddf
diff --git a/snmp_util.cpp b/snmp_util.cpp
index 9f235d8..9516337 100644
--- a/snmp_util.cpp
+++ b/snmp_util.cpp
@@ -26,15 +26,17 @@
                                       "org.freedesktop.DBus.ObjectManager",
                                       "GetManagedObjects");
 
-    auto reply = bus.call(method);
-
-    if (reply.is_method_error())
+    try
+    {
+        auto reply = bus.call(method);
+        reply.read(interfaces);
+    }
+    catch (const sdbusplus::exception::exception& e)
     {
         lg2::error("Failed to get managed objects: {PATH}", "PATH", objPath);
         elog<InternalFailure>();
     }
 
-    reply.read(interfaces);
     return interfaces;
 }