Remove is_method_error method
Remove the usage of is_method_error()[1], and add try-catch to handle
D-Bus exceptions around mapper call.
[1]https://github.com/openbmc/sdbusplus/commit/079fb85a398d90800935e3985bb1266a7530a26e#diff-945669e8bd9cab4ecc83a574a732921281b2c79eb8bba65efff11736ad18f92bR237-R240
Signed-off-by: George Liu <liuxiwei@inspur.com>
Change-Id: I85192219c1c34cf5fd6c6aca06a8b207d7e06697
diff --git a/storagehandler.cpp b/storagehandler.cpp
index 0ac735b..0a7ac1c 100644
--- a/storagehandler.cpp
+++ b/storagehandler.cpp
@@ -466,8 +466,11 @@
auto methodCall = bus.new_method_call(service.c_str(), objPath.c_str(),
ipmi::sel::logDeleteIntf, "Delete");
- auto reply = bus.call(methodCall);
- if (reply.is_method_error())
+ try
+ {
+ auto reply = bus.call(methodCall);
+ }
+ catch (const std::exception& e)
{
return ipmi::responseUnspecifiedError();
}
@@ -556,13 +559,6 @@
method.append(TIME_INTERFACE, PROPERTY_ELAPSED);
auto reply = bus.call(method);
- if (reply.is_method_error())
- {
- log<level::ERR>("Error getting time",
- entry("SERVICE=%s", service.c_str()),
- entry("PATH=%s", BMC_TIME_PATH));
- return ipmi::responseUnspecifiedError();
- }
reply.read(value);
bmc_time_usec = std::get<uint64_t>(value);
}
@@ -618,13 +614,6 @@
method.append(TIME_INTERFACE, PROPERTY_ELAPSED, value);
auto reply = bus.call(method);
- if (reply.is_method_error())
- {
- log<level::ERR>("Error setting time",
- entry("SERVICE=%s", service.c_str()),
- entry("PATH=%s", BMC_TIME_PATH));
- return ipmi::responseUnspecifiedError();
- }
}
catch (const InternalFailure& e)
{