Set error code for getFruPathFromJson API
This commit updates getFruPathFromJson API to set error code in case of
error. This helps caller of API to take action based on the error code
returned from the API.
Change-Id: I66f22e997119bc93ad3ae88e21c4d4d6e8951c3f
Signed-off-by: Rekha Aparna <vrekhaaparna@ibm.com>
diff --git a/vpd-manager/src/worker.cpp b/vpd-manager/src/worker.cpp
index b5b3780..04f060f 100644
--- a/vpd-manager/src/worker.cpp
+++ b/vpd-manager/src/worker.cpp
@@ -1688,8 +1688,18 @@
throw std::runtime_error("Given DBus object path is empty.");
}
+ uint16_t l_errCode = 0;
const std::string& l_fruPath =
- jsonUtility::getFruPathFromJson(m_parsedJson, i_dbusObjPath);
+ jsonUtility::getFruPathFromJson(m_parsedJson, i_dbusObjPath, l_errCode);
+
+ if (l_errCode)
+ {
+ logging::logMessage(
+ "Failed to get FRU path for inventory path [" + i_dbusObjPath +
+ "], error : " + vpdSpecificUtility::getErrCodeMsg(l_errCode) +
+ " Aborting FRU VPD deletion.");
+ return;
+ }
try
{
@@ -1922,6 +1932,8 @@
const sdbusplus::message::object_path& i_dbusObjPath)
{
std::string l_fruPath{};
+ uint16_t l_errCode = 0;
+
try
{
// Check if system config JSON is present
@@ -1934,11 +1946,21 @@
}
// Get FRU path for the given D-bus object path from JSON
- l_fruPath =
- jsonUtility::getFruPathFromJson(m_parsedJson, i_dbusObjPath);
+ l_fruPath = jsonUtility::getFruPathFromJson(m_parsedJson, i_dbusObjPath,
+ l_errCode);
if (l_fruPath.empty())
{
+ if (l_errCode)
+ {
+ logging::logMessage(
+ "Failed to get FRU path for [" +
+ std::string(i_dbusObjPath) + "], error : " +
+ vpdSpecificUtility::getErrCodeMsg(l_errCode) +
+ " Aborting single FRU VPD collection.");
+ return;
+ }
+
logging::logMessage(
"D-bus object path not present in JSON. Single FRU VPD collection is not performed for " +
std::string(i_dbusObjPath));