Use sdbusplus exception instead of the custom one
Currently mapper generates custom 'NotFoundException' exception when
a path is not found in the object list.
Instead of creating another exception use 'ResourceNotFound' exception
from the sdbusplus library.
Signed-off-by: Konstantin Aladyshev <aladyshev22@gmail.com>
Change-Id: Ic4fa9d2eac56dc79782e7453113574197ffce49b
diff --git a/src/main.cpp b/src/main.cpp
index 53b36d5..7fd2b10 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -15,35 +15,13 @@
#include <iostream>
#include <sdbusplus/asio/connection.hpp>
#include <sdbusplus/asio/object_server.hpp>
+#include <xyz/openbmc_project/Common/error.hpp>
AssociationMaps associationMaps;
static WhiteBlackList service_whitelist;
static WhiteBlackList service_blacklist;
-/** Exception thrown when a path is not found in the object list. */
-struct NotFoundException final : public sdbusplus::exception_t
-{
- const char* name() const noexcept override
- {
- return "xyz.openbmc_project.Common.Error.ResourceNotFound";
- };
- const char* description() const noexcept override
- {
- return "path or object not found";
- };
- const char* what() const noexcept override
- {
- return "xyz.openbmc_project.Common.Error.ResourceNotFound: "
- "The resource is not found.";
- };
-
- int get_errno() const noexcept override
- {
- return ENOENT;
- }
-};
-
void update_owners(sdbusplus::asio::connection* conn,
boost::container::flat_map<std::string, std::string>& owners,
const std::string& new_object)
@@ -465,7 +443,8 @@
}
if (req_path.size() && interface_map.find(req_path) == interface_map.end())
{
- throw NotFoundException();
+ throw sdbusplus::xyz::openbmc_project::Common::Error::
+ ResourceNotFound();
}
std::vector<interface_map_type::value_type> ret;
@@ -510,7 +489,8 @@
auto path_ref = interface_map.find(path);
if (path_ref == interface_map.end())
{
- throw NotFoundException();
+ throw sdbusplus::xyz::openbmc_project::Common::Error::
+ ResourceNotFound();
}
if (interfaces.empty())
{
@@ -527,7 +507,8 @@
if (results.empty())
{
- throw NotFoundException();
+ throw sdbusplus::xyz::openbmc_project::Common::Error::
+ ResourceNotFound();
}
return results;
@@ -551,7 +532,8 @@
}
if (req_path.size() && interface_map.find(req_path) == interface_map.end())
{
- throw NotFoundException();
+ throw sdbusplus::xyz::openbmc_project::Common::Error::
+ ResourceNotFound();
}
for (auto& object_path : interface_map)
@@ -606,7 +588,8 @@
}
if (req_path.size() && interface_map.find(req_path) == interface_map.end())
{
- throw NotFoundException();
+ throw sdbusplus::xyz::openbmc_project::Common::Error::
+ ResourceNotFound();
}
for (auto& object_path : interface_map)