Error code for vpdSpecificUtility APIs

This commit updates getVpdDataInVector and getDbusPropNameForGivenKw
APIs to set error code in case of error. This helps the caller of API
to take action based on the error code returned from the API.

Change-Id: I77bcb4b81a8ebaa196a9bdef3050ad3dfebd07e0
Signed-off-by: Rekha Aparna <vrekhaaparna@ibm.com>
diff --git a/vpd-manager/include/utility/vpd_specific_utility.hpp b/vpd-manager/include/utility/vpd_specific_utility.hpp
index 7cb0a35..4120cbf 100644
--- a/vpd-manager/include/utility/vpd_specific_utility.hpp
+++ b/vpd-manager/include/utility/vpd_specific_utility.hpp
@@ -491,11 +491,18 @@
  * @param[in] vpdFilePath - EEPROM path of the FRU.
  * @param[out] vpdVector - VPD in vector form.
  * @param[in] vpdStartOffset - Offset of VPD data in EEPROM.
+ * @param[out] o_errCode - To set error code in case of error.
  */
 inline void getVpdDataInVector(const std::string& vpdFilePath,
                                types::BinaryVector& vpdVector,
-                               size_t& vpdStartOffset)
+                               size_t& vpdStartOffset, uint16_t& o_errCode)
 {
+    if (vpdFilePath.empty())
+    {
+        o_errCode = error_code::INVALID_INPUT_PARAMETER;
+        return;
+    }
+
     try
     {
         std::fstream vpdFileStream;
@@ -515,9 +522,8 @@
     }
     catch (const std::ifstream::failure& fail)
     {
-        std::cerr << "Exception in file handling [" << vpdFilePath
-                  << "] error : " << fail.what();
-        throw;
+        o_errCode = error_code::FILE_SYSTEM_ERROR;
+        return;
     }
 }
 
@@ -525,11 +531,18 @@
  * @brief An API to get D-bus representation of given VPD keyword.
  *
  * @param[in] i_keywordName - VPD keyword name.
+ * @param[out] o_errCode - To set error code in case of error.
  *
  * @return D-bus representation of given keyword.
  */
-inline std::string getDbusPropNameForGivenKw(const std::string& i_keywordName)
+inline std::string getDbusPropNameForGivenKw(const std::string& i_keywordName,
+                                             uint16_t& o_errCode)
 {
+    if (i_keywordName.empty())
+    {
+        o_errCode = error_code::INVALID_INPUT_PARAMETER;
+        return std::string{};
+    }
     // Check for "#" prefixed VPD keyword.
     if ((i_keywordName.size() == vpd::constants::TWO_BYTES) &&
         (i_keywordName.at(0) == constants::POUND_KW))