Set error code for executePostFailAction API

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

Change-Id: Iaec2506e62307bb041d7b37469d0e4b6b75741f1
Signed-off-by: Rekha Aparna <vrekhaaparna@ibm.com>
diff --git a/vpd-manager/src/worker.cpp b/vpd-manager/src/worker.cpp
index ca9df5a..2521606 100644
--- a/vpd-manager/src/worker.cpp
+++ b/vpd-manager/src/worker.cpp
@@ -1342,6 +1342,7 @@
     }
     catch (std::exception& l_ex)
     {
+        uint16_t l_errCode = 0;
         std::string l_exMsg{
             std::string(__FUNCTION__) + " : VPD parsing failed for " +
             i_vpdFilePath + " due to error: " + l_ex.what()};
@@ -1351,10 +1352,11 @@
                                           "postFailAction", "collection"))
         {
             if (!jsonUtility::executePostFailAction(m_parsedJson, i_vpdFilePath,
-                                                    "collection"))
+                                                    "collection", l_errCode))
             {
-                l_exMsg +=
-                    ". Post Fail Action also failed, aborting collection for this FRU";
+                l_exMsg += ". Post fail action also failed. Error : " +
+                           vpdSpecificUtility::getErrCodeMsg(l_errCode) +
+                           " Aborting collection for this FRU.";
             }
         }
 
@@ -1768,19 +1770,23 @@
     }
     catch (const std::exception& l_ex)
     {
+        uint16_t l_errCode = 0;
+        std::string l_errMsg =
+            "Failed to delete VPD for FRU : " + i_dbusObjPath +
+            " error: " + std::string(l_ex.what());
+
         if (jsonUtility::isActionRequired(m_parsedJson, l_fruPath,
                                           "postFailAction", "deletion"))
         {
             if (!jsonUtility::executePostFailAction(m_parsedJson, l_fruPath,
-                                                    "deletion"))
+                                                    "deletion", l_errCode))
             {
-                logging::logMessage(
-                    "Post fail action failed for: " + i_dbusObjPath);
+                l_errMsg += ". Post fail action also failed, error : " +
+                            vpdSpecificUtility::getErrCodeMsg(l_errCode);
             }
         }
 
-        logging::logMessage("Failed to delete VPD for FRU : " + i_dbusObjPath +
-                            " error: " + std::string(l_ex.what()));
+        logging::logMessage(l_errMsg);
     }
 }