Continue execution on any GPIO exception

In case there is any issue with reading of presence GPIO, the code
should check if the required EEPROM file exists.
If found and can be parsed then instead of exiting collection for the
FRU, the code will log an informational PEL for the error and will
continue with the execution.
This is required so that we don't exit collection for an intermediate
error when the collection can be successfully done.

Change-Id: I889668a0e765cc6df7e5df174c7a80c133892d18
Signed-off-by: Sunny Srivastava <sunnsr25@in.ibm.com>
diff --git a/vpd-manager/include/types.hpp b/vpd-manager/include/types.hpp
index b4dc22e..09153f4 100644
--- a/vpd-manager/include/types.hpp
+++ b/vpd-manager/include/types.hpp
@@ -186,6 +186,7 @@
     InternalFailure, /* Should be used for any generic firmware failure */
     FruMissing, /* Should be used in case of presence failure */
     SystemTypeMismatch,
+    UndefinedError,
     UnknownSystemSettings,
     FirmwareError
 };
diff --git a/vpd-manager/include/utility/json_utility.hpp b/vpd-manager/include/utility/json_utility.hpp
index 990abb2..4b44179 100644
--- a/vpd-manager/include/utility/json_utility.hpp
+++ b/vpd-manager/include/utility/json_utility.hpp
@@ -370,7 +370,12 @@
     }
     catch (const std::exception& l_ex)
     {
-        if (EventLogger::getErrorType(l_ex) != types::ErrorType::GpioError)
+        // No need to continue in case of JSON failure or Firmware error
+        // as these are errors internal to the code and in that case the FRU
+        // should not be processed. Any other error is considered as external
+        // error in this case and a try to read the EEPROM should be done.
+        if (EventLogger::getErrorType(l_ex) == types::ErrorType::JsonFailure ||
+            EventLogger::getErrorType(l_ex) == types::ErrorType::FirmwareError)
         {
             EventLogger::createSyncPel(
                 EventLogger::getErrorType(l_ex),
diff --git a/vpd-manager/src/event_logger.cpp b/vpd-manager/src/event_logger.cpp
index c59c8ba..d5bf3d2 100644
--- a/vpd-manager/src/event_logger.cpp
+++ b/vpd-manager/src/event_logger.cpp
@@ -29,6 +29,7 @@
 const std::unordered_map<types::ErrorType, std::string>
     EventLogger::m_errorMsgMap = {
         {types::ErrorType::DefaultValue, "com.ibm.VPD.Error.DefaultValue"},
+        {types::ErrorType::UndefinedError, "com.ibm.VPD.Error.UndefinedError"},
         {types::ErrorType::InvalidVpdMessage, "com.ibm.VPD.Error.InvalidVPD"},
         {types::ErrorType::VpdMismatch, "com.ibm.VPD.Error.Mismatch"},
         {types::ErrorType::InvalidEeprom,
@@ -305,7 +306,7 @@
     const std::exception& i_exception)
 {
     types::ExceptionDataMap l_errorInfo{
-        {"ErrorType", types::ErrorType::FirmwareError},
+        {"ErrorType", types::ErrorType::UndefinedError},
         {"ErrorMsg", i_exception.what()}};
 
     try
@@ -367,6 +368,14 @@
             l_errorInfo["ErrorMsg"] =
                 std::string("Eeprom Exception. Reason: ") + i_exception.what();
         }
+        else if (typeid(i_exception) == typeid(std::runtime_error))
+        {
+            // Since it is a standard exception no casting is required and error
+            // type is hardcoded.
+            l_errorInfo["ErrorType"] = types::ErrorType::FirmwareError;
+            l_errorInfo["ErrorMsg"] =
+                std::string("Eeprom Exception. Reason: ") + i_exception.what();
+        }
     }
     catch (const std::exception& l_ex)
     {
@@ -383,14 +392,14 @@
     auto l_itrToErrType = l_exceptionDataMap.find("ErrorType");
     if (l_itrToErrType == l_exceptionDataMap.end())
     {
-        return types::ErrorType::FirmwareError;
+        return types::ErrorType::UndefinedError;
     }
 
     auto l_ptrToErrType =
         std::get_if<types::ErrorType>(&l_itrToErrType->second);
     if (!l_ptrToErrType)
     {
-        return types::ErrorType::FirmwareError;
+        return types::ErrorType::UndefinedError;
     }
 
     return *l_ptrToErrType;