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: Id3c0358431d0d899b4d899b5d74d954426370aba
diff --git a/settings.cpp b/settings.cpp
index 65df0ea..c136c22 100644
--- a/settings.cpp
+++ b/settings.cpp
@@ -25,18 +25,22 @@
mapperCall.append(root);
mapperCall.append(depth);
mapperCall.append(settingsIntfs);
- auto response = bus.call(mapperCall);
- if (response.is_method_error())
- {
- log<level::ERR>("Error in mapper GetSubTree");
- elog<InternalFailure>();
- }
using Interfaces = std::vector<Interface>;
using MapperResponse = std::vector<
std::pair<Path, std::vector<std::pair<Service, Interfaces>>>>;
MapperResponse result;
- response.read(result);
+
+ try
+ {
+ auto response = bus.call(mapperCall);
+ response.read(result);
+ }
+ catch (const sdbusplus::exception::exception& ex)
+ {
+ log<level::ERR>("Failed to invoke GetSubTree method");
+ }
+
if (result.empty())
{
log<level::ERR>("Invalid response from mapper");
@@ -67,15 +71,17 @@
mapperCall.append(path);
mapperCall.append(Interfaces({interface}));
- auto response = bus.call(mapperCall);
- if (response.is_method_error())
+ std::map<Service, Interfaces> result;
+ try
+ {
+ auto response = bus.call(mapperCall);
+ response.read(result);
+ }
+ catch (const sdbusplus::exception::exception& ex)
{
log<level::ERR>("Error in mapper GetObject");
- elog<InternalFailure>();
}
- std::map<Service, Interfaces> result;
- response.read(result);
if (result.empty())
{
log<level::ERR>("Invalid response from mapper");