ramoops_manager: Handle D-Bus exceptions
Remove the deprecated is_method_error() method, and add try-catch to
handle the exceptions.
Signed-off-by: George Liu <liuxiwei@inspur.com>
Change-Id: Ibd12f1fdf05aede82bfc8b3c58e4cfd6a8e3c612
diff --git a/ramoops_manager.cpp b/ramoops_manager.cpp
index 5fed14b..16ec7e8 100644
--- a/ramoops_manager.cpp
+++ b/ramoops_manager.cpp
@@ -40,24 +40,17 @@
MAPPER_INTERFACE, "GetObject");
mapper.append(OBJ_INTERNAL, std::set<std::string>({IFACE_INTERNAL}));
- auto mapperResponseMsg = b.call(mapper);
- if (mapperResponseMsg.is_method_error())
- {
- log<level::ERR>("Error in mapper call");
- return;
- }
-
std::map<std::string, std::set<std::string>> mapperResponse;
try
{
+ auto mapperResponseMsg = b.call(mapper);
mapperResponseMsg.read(mapperResponse);
}
catch (const sdbusplus::exception::SdBusError& e)
{
log<level::ERR>(
- fmt::format(
- "Failed to parse dump create message, error({}), REPLY_SIG({})",
- e.what(), mapperResponseMsg.get_signature())
+ fmt::format("Failed to parse dump create message, error({})",
+ e.what())
.c_str());
return;
}
@@ -71,7 +64,16 @@
auto m =
b.new_method_call(host.c_str(), OBJ_INTERNAL, IFACE_INTERNAL, "Create");
m.append(RAMOOPS, files);
- b.call_noreply(m);
+ try
+ {
+ b.call_noreply(m);
+ }
+ catch (const sdbusplus::exception::SdBusError& e)
+ {
+ log<level::ERR>(
+ fmt::format("Failed to create ramoops dump, errormsg({})", e.what())
+ .c_str());
+ }
}
} // namespace ramoops