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/test/utest_json_utility.cpp b/test/utest_json_utility.cpp
index 4f0b5c5..283640f 100644
--- a/test/utest_json_utility.cpp
+++ b/test/utest_json_utility.cpp
@@ -1,6 +1,7 @@
 #include "parser.hpp"
 #include "types.hpp"
 #include "utility/json_utility.hpp"
+#include "utility/vpd_specific_utility.hpp"
 
 #include <iostream>
 
@@ -10,9 +11,19 @@
 
 TEST(IsFruPowerOffOnlyTest, PositiveTestCase)
 {
+    uint16_t l_errCode = 0;
     const std::string l_jsonPath{"/usr/local/share/vpd/50001001.json"};
     const std::string l_vpdPath{"/sys/bus/spi/drivers/at25/spi12.0/eeprom"};
-    const nlohmann::json l_parsedJson = jsonUtility::getParsedJson(l_jsonPath);
+    const nlohmann::json l_parsedJson =
+        jsonUtility::getParsedJson(l_jsonPath, l_errCode);
+
+    if (l_errCode)
+    {
+        logging::logMessage(
+            "Failed to parse JSON file [" + l_jsonPath +
+            "], error : " + vpdSpecificUtility::getErrCodeMsg(l_errCode));
+    }
+
     const bool l_result =
         jsonUtility::isFruPowerOffOnly(l_parsedJson, l_vpdPath);
     EXPECT_TRUE(l_result);
@@ -20,9 +31,19 @@
 
 TEST(IsFruPowerOffOnlyTest, NegativeTestCase)
 {
+    uint16_t l_errCode = 0;
     const std::string l_jsonPath{"/usr/local/share/vpd/50001001.json"};
     const std::string l_vpdPath{"/sys/bus/i2c/drivers/at24/4-0050/eeprom"};
-    const nlohmann::json l_parsedJson = jsonUtility::getParsedJson(l_jsonPath);
+    const nlohmann::json l_parsedJson =
+        jsonUtility::getParsedJson(l_jsonPath, l_errCode);
+
+    if (l_errCode)
+    {
+        logging::logMessage(
+            "Failed to parse JSON file [" + l_jsonPath +
+            "], error : " + vpdSpecificUtility::getErrCodeMsg(l_errCode));
+    }
+
     const bool l_result =
         jsonUtility::isFruPowerOffOnly(l_parsedJson, l_vpdPath);
     EXPECT_FALSE(l_result);