Error handling for resetDataUnderPIM API

This commit updates resetDataUnderPIM API 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: I71427b473d3094d0b2ea357cdde4d6c4d2627d2b
Signed-off-by: Rekha Aparna <vrekhaaparna@ibm.com>
diff --git a/vpd-manager/src/worker.cpp b/vpd-manager/src/worker.cpp
index b04c431..a6970aa 100644
--- a/vpd-manager/src/worker.cpp
+++ b/vpd-manager/src/worker.cpp
@@ -1717,16 +1717,34 @@
                 for (const auto& [l_objectPath, l_serviceInterfaceMap] :
                      l_subTreeMap)
                 {
+                    l_errCode = 0;
                     types::InterfaceMap l_interfaceMap;
-                    vpdSpecificUtility::resetDataUnderPIM(l_objectPath,
-                                                          l_interfaceMap);
+                    vpdSpecificUtility::resetDataUnderPIM(
+                        l_objectPath, l_interfaceMap, l_errCode);
+
+                    if (l_errCode)
+                    {
+                        throw std::runtime_error(
+                            "Failed to reset data under PIM for sub FRU [" +
+                            l_objectPath + "], error : " +
+                            commonUtility::getErrCodeMsg(l_errCode));
+                    }
+
                     l_objectMap.emplace(l_objectPath,
                                         std::move(l_interfaceMap));
                 }
 
+                l_errCode = 0;
                 types::InterfaceMap l_interfaceMap;
-                vpdSpecificUtility::resetDataUnderPIM(i_dbusObjPath,
-                                                      l_interfaceMap);
+                vpdSpecificUtility::resetDataUnderPIM(
+                    i_dbusObjPath, l_interfaceMap, l_errCode);
+
+                if (l_errCode)
+                {
+                    throw std::runtime_error(
+                        "Failed to reset data under PIM, error : " +
+                        commonUtility::getErrCodeMsg(l_errCode));
+                }
 
                 l_objectMap.emplace(i_dbusObjPath, std::move(l_interfaceMap));