Set error code for getParsedJson API
This commit updates getParsedJson API to set error codes in case of
error. This helps caller of the API to take action based on the error
code returned from the API.
Change-Id: I0b88806bbc2201ae162e1714613fa6a9bfe3df9d
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 61d5ba5..89d7d2a 100644
--- a/vpd-manager/src/backup_restore.cpp
+++ b/vpd-manager/src/backup_restore.cpp
@@ -21,13 +21,16 @@
std::string l_backupAndRestoreCfgFilePath =
i_sysCfgJsonObj.value("backupRestoreConfigPath", "");
+ uint16_t l_errCode = 0;
m_backupAndRestoreCfgJsonObj =
- jsonUtility::getParsedJson(l_backupAndRestoreCfgFilePath);
+ jsonUtility::getParsedJson(l_backupAndRestoreCfgFilePath, l_errCode);
- if (m_backupAndRestoreCfgJsonObj.empty())
+ if (l_errCode)
{
- throw JsonException("JSON parsing failed",
- l_backupAndRestoreCfgFilePath);
+ throw JsonException(
+ "JSON parsing failed for file [" + l_backupAndRestoreCfgFilePath +
+ "], error : " + vpdSpecificUtility::getErrCodeMsg(l_errCode),
+ l_backupAndRestoreCfgFilePath);
}
}