Remove deprecated is_method_error code

The is_method_error() function is no longer needed, instead a
try-catch block should be used instead.
Reference:
https://lists.ozlabs.org/pipermail/openbmc/2018-October/013696.html

Tested: Code update with field mode enabled, and ran Delete while
        host powered on, to check things still worked as expected.

Change-Id: I8ba8da32fe787c3151cc5be7cb9f55d1901e57cd
Signed-off-by: Adriana Kobylak <anoo@us.ibm.com>
diff --git a/item_updater.cpp b/item_updater.cpp
index f321b02..882acbb 100644
--- a/item_updater.cpp
+++ b/item_updater.cpp
@@ -214,38 +214,47 @@
 
     mapperCall.append(CHASSIS_STATE_PATH,
                       std::vector<std::string>({CHASSIS_STATE_OBJ}));
-    auto mapperResponseMsg = bus.call(mapperCall);
-    if (mapperResponseMsg.is_method_error())
+
+    std::map<std::string, std::vector<std::string>> mapperResponse;
+
+    try
+    {
+        auto mapperResponseMsg = bus.call(mapperCall);
+        mapperResponseMsg.read(mapperResponse);
+        if (mapperResponse.empty())
+        {
+            log<level::ERR>("Invalid Response from mapper");
+            elog<InternalFailure>();
+        }
+    }
+    catch (const sdbusplus::exception::SdBusError& e)
     {
         log<level::ERR>("Error in Mapper call");
         elog<InternalFailure>();
     }
-    using MapperResponseType = std::map<std::string, std::vector<std::string>>;
-    MapperResponseType mapperResponse;
-    mapperResponseMsg.read(mapperResponse);
-    if (mapperResponse.empty())
-    {
-        log<level::ERR>("Invalid Response from mapper");
-        elog<InternalFailure>();
-    }
 
     auto method = bus.new_method_call((mapperResponse.begin()->first).c_str(),
                                       CHASSIS_STATE_PATH,
                                       SYSTEMD_PROPERTY_INTERFACE, "Get");
     method.append(CHASSIS_STATE_OBJ, "CurrentPowerState");
-    auto response = bus.call(method);
-    if (response.is_method_error())
+
+    sdbusplus::message::variant<std::string> currentChassisState;
+
+    try
+    {
+        auto response = bus.call(method);
+        response.read(currentChassisState);
+        auto strParam = sdbusplus::message::variant_ns::get<std::string>(
+            currentChassisState);
+        return (strParam != CHASSIS_STATE_OFF);
+    }
+    catch (const sdbusplus::exception::SdBusError& e)
     {
         log<level::ERR>("Error in fetching current Chassis State",
                         entry("MAPPERRESPONSE=%s",
                               (mapperResponse.begin()->first).c_str()));
         elog<InternalFailure>();
     }
-    sdbusplus::message::variant<std::string> currentChassisState;
-    response.read(currentChassisState);
-    auto strParam =
-        sdbusplus::message::variant_ns::get<std::string>(currentChassisState);
-    return (strParam != CHASSIS_STATE_OFF);
 }
 
 } // namespace updater