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/backup_restore.cpp b/vpd-manager/src/backup_restore.cpp
index 89d7d2a..0a8d844 100644
--- a/vpd-manager/src/backup_restore.cpp
+++ b/vpd-manager/src/backup_restore.cpp
@@ -154,10 +154,30 @@
return;
}
+ uint16_t l_errCode = 0;
+
const std::string l_srcFruPath =
- jsonUtility::getFruPathFromJson(m_sysCfgJsonObj, i_srcPath);
+ jsonUtility::getFruPathFromJson(m_sysCfgJsonObj, i_srcPath, l_errCode);
+
+ if (l_errCode)
+ {
+ logging::logMessage(
+ "Failed to get source FRU path for [" + i_srcPath +
+ "], error : " + vpdSpecificUtility::getErrCodeMsg(l_errCode));
+ return;
+ }
+
const std::string l_dstFruPath =
- jsonUtility::getFruPathFromJson(m_sysCfgJsonObj, i_dstPath);
+ jsonUtility::getFruPathFromJson(m_sysCfgJsonObj, i_dstPath, l_errCode);
+
+ if (l_errCode)
+ {
+ logging::logMessage(
+ "Failed to get destination FRU path for [" + i_dstPath +
+ "], error : " + vpdSpecificUtility::getErrCodeMsg(l_errCode));
+ return;
+ }
+
if (l_srcFruPath.empty() || l_dstFruPath.empty())
{
logging::logMessage(
@@ -165,7 +185,6 @@
return;
}
- uint16_t l_errCode = 0;
const std::string l_srcInvPath = jsonUtility::getInventoryObjPathFromJson(
m_sysCfgJsonObj, i_srcPath, l_errCode);