Refactor find CCIN in VPD API exception handling

This commit refactors vpd specific utility API used to find CCIN in VPD,
in order to handle any exceptions thrown by it locally. All utility
methods should handle exceptions locally and log a journal log in case
of failure. The caller of the utility APIs should check the return value
to detect success/failure.

This commit also logs a PEL in case VINI record or empty CCIN is found
for any FRU.

Test:
```
- Install bitbaked image on Everest
- After BMC becomes ready, check vpd-manager log to check postAction
  collection is successful for pcieslot2/pcie_card2
```

Change-Id: I19ef8e9d67bdfdaab9876c9df5c04fa6f0c08f79
Signed-off-by: Souvik Roy <souvikroyofficial10@gmail.com>
diff --git a/vpd-manager/include/utility/vpd_specific_utility.hpp b/vpd-manager/include/utility/vpd_specific_utility.hpp
index 6b2f685..9bed952 100644
--- a/vpd-manager/include/utility/vpd_specific_utility.hpp
+++ b/vpd-manager/include/utility/vpd_specific_utility.hpp
@@ -3,6 +3,7 @@
 #include "config.h"
 
 #include "constants.hpp"
+#include "event_logger.hpp"
 #include "exceptions.hpp"
 #include "logger.hpp"
 #include "types.hpp"
@@ -14,6 +15,7 @@
 #include <filesystem>
 #include <fstream>
 #include <regex>
+#include <typeindex>
 
 namespace vpd
 {
@@ -461,59 +463,83 @@
  * The API will check from parsed VPD map if the FRU is the one with desired
  * CCIN.
  *
- * @throw std::runtime_error
- * @throw DataException
- *
  * @param[in] i_JsonObject - Any JSON which contains CCIN tag to match.
  * @param[in] i_parsedVpdMap - Parsed VPD map.
+ *
  * @return True if found, false otherwise.
  */
 inline bool findCcinInVpd(const nlohmann::json& i_JsonObject,
-                          const types::VPDMapVariant& i_parsedVpdMap)
+                          const types::VPDMapVariant& i_parsedVpdMap) noexcept
 {
-    if (i_JsonObject.empty())
+    bool l_rc{false};
+    try
     {
-        throw std::runtime_error("Json object is empty. Can't find CCIN");
-    }
-
-    if (auto l_ipzVPDMap = std::get_if<types::IPZVpdMap>(&i_parsedVpdMap))
-    {
-        auto l_itrToRec = (*l_ipzVPDMap).find("VINI");
-        if (l_itrToRec == (*l_ipzVPDMap).end())
+        if (i_JsonObject.empty())
         {
-            throw DataException(
-                "VINI record not found in parsed VPD. Can't find CCIN");
+            throw std::runtime_error("Json object is empty. Can't find CCIN");
         }
 
-        std::string l_ccinFromVpd;
-        vpdSpecificUtility::getKwVal(l_itrToRec->second, "CC", l_ccinFromVpd);
-        if (l_ccinFromVpd.empty())
+        if (auto l_ipzVPDMap = std::get_if<types::IPZVpdMap>(&i_parsedVpdMap))
         {
-            throw DataException("Empty CCIN value in VPD map. Can't find CCIN");
-        }
-
-        transform(l_ccinFromVpd.begin(), l_ccinFromVpd.end(),
-                  l_ccinFromVpd.begin(), ::toupper);
-
-        for (std::string l_ccinValue : i_JsonObject["ccin"])
-        {
-            transform(l_ccinValue.begin(), l_ccinValue.end(),
-                      l_ccinValue.begin(), ::toupper);
-
-            if (l_ccinValue.compare(l_ccinFromVpd) ==
-                constants::STR_CMP_SUCCESS)
+            auto l_itrToRec = (*l_ipzVPDMap).find("VINI");
+            if (l_itrToRec == (*l_ipzVPDMap).end())
             {
-                // CCIN found
-                return true;
+                throw DataException(
+                    "VINI record not found in parsed VPD. Can't find CCIN");
+            }
+
+            std::string l_ccinFromVpd;
+            vpdSpecificUtility::getKwVal(l_itrToRec->second, "CC",
+                                         l_ccinFromVpd);
+            if (l_ccinFromVpd.empty())
+            {
+                throw DataException(
+                    "Empty CCIN value in VPD map. Can't find CCIN");
+            }
+
+            transform(l_ccinFromVpd.begin(), l_ccinFromVpd.end(),
+                      l_ccinFromVpd.begin(), ::toupper);
+
+            for (std::string l_ccinValue : i_JsonObject["ccin"])
+            {
+                transform(l_ccinValue.begin(), l_ccinValue.end(),
+                          l_ccinValue.begin(), ::toupper);
+
+                if (l_ccinValue.compare(l_ccinFromVpd) ==
+                    constants::STR_CMP_SUCCESS)
+                {
+                    // CCIN found
+                    l_rc = true;
+                }
+            }
+
+            if (!l_rc)
+            {
+                logging::logMessage("No match found for CCIN");
             }
         }
-
-        logging::logMessage("No match found for CCIN");
-        return false;
+        else
+        {
+            logging::logMessage("VPD type not supported. Can't find CCIN");
+        }
     }
+    catch (const std::exception& l_ex)
+    {
+        const std::string l_errMsg{
+            "Failed to find CCIN in VPD. Error : " + std::string(l_ex.what())};
 
-    logging::logMessage("VPD type not supported. Can't find CCIN");
-    return false;
+        if (typeid(l_ex) == std::type_index(typeid(DataException)))
+        {
+            EventLogger::createSyncPel(
+                types::ErrorType::InvalidVpdMessage,
+                types::SeverityType::Informational, __FILE__, __FUNCTION__, 0,
+                l_errMsg, std::nullopt, std::nullopt, std::nullopt,
+                std::nullopt);
+        }
+
+        logging::logMessage(l_errMsg);
+    }
+    return l_rc;
 }
 
 /**