Don't fail on empty SEL list
If SEL list is empty, "GetSubTreePaths" method call to the
"xyz.openbmc_project.ObjectMapper" interface produces exception
"xyz.openbmc_project.Common.Error.ResourceNotFound".
As it is fine for the SEL log to be empty, this exception needs
special handling in the code.
Signed-off-by: Konstantin Aladyshev <aladyshev22@gmail.com>
Change-Id: If7ecfee7c404aff079dadaaec27401c9c17daa6f
diff --git a/selutility.cpp b/selutility.cpp
index 11b2fb9..e02027f 100644
--- a/selutility.cpp
+++ b/selutility.cpp
@@ -407,26 +407,30 @@
mapperCall.append(depth);
mapperCall.append(ObjectPaths({logEntryIntf}));
- auto reply = bus.call(mapperCall);
- if (reply.is_method_error())
+ try
{
- log<level::INFO>("Error in reading logging entry object paths");
- }
- else
- {
+ auto reply = bus.call(mapperCall);
reply.read(paths);
-
- std::sort(paths.begin(), paths.end(),
- [](const std::string& a, const std::string& b) {
- namespace fs = std::filesystem;
- fs::path pathA(a);
- fs::path pathB(b);
- auto idA = std::stoul(pathA.filename().string());
- auto idB = std::stoul(pathB.filename().string());
-
- return idA < idB;
- });
}
+ catch (const sdbusplus::exception::exception& e)
+ {
+ if (strcmp(e.name(),
+ "xyz.openbmc_project.Common.Error.ResourceNotFound"))
+ {
+ throw;
+ }
+ }
+
+ std::sort(paths.begin(), paths.end(),
+ [](const std::string& a, const std::string& b) {
+ namespace fs = std::filesystem;
+ fs::path pathA(a);
+ fs::path pathB(b);
+ auto idA = std::stoul(pathA.filename().string());
+ auto idB = std::stoul(pathB.filename().string());
+
+ return idA < idB;
+ });
}
} // namespace sel