Fix exception type loss while parsing VPD
This commit includes changes to prevent loss of exception type while
parsing VPD. In case of Data/ECC exception while parsing IPZ VPD, the
exception type was lost. This commit also handles setting PEL severity
in case of Data/ECC exception. In case of Data/ECC exception while
parsing VPD, predictive PEL must be logged.
Test:
```
- On rainier 2s2u simics system, corrupt VHDR data of base op panel
- On rainier 2s2u simics system, corrupt VHDR ECC of op LCD panel
- Restart vpd-manager
- Check PELs using peltool
- Observe 2 predictive PELs logged with Data Exception and ECC Exception
respectively
```
Change-Id: I21e5b668aa70cc13916475792e38e5822c00117e
Signed-off-by: Souvik Roy <souvikroyofficial10@gmail.com>
diff --git a/vpd-manager/src/event_logger.cpp b/vpd-manager/src/event_logger.cpp
index 508832f..900361a 100644
--- a/vpd-manager/src/event_logger.cpp
+++ b/vpd-manager/src/event_logger.cpp
@@ -472,7 +472,8 @@
// type is hardcoded.
l_errorInfo["ErrorType"] = types::ErrorType::FirmwareError;
l_errorInfo["ErrorMsg"] =
- std::string("Eeprom Exception. Reason: ") + i_exception.what();
+ std::string("Standard runtime exception. Reason: ") +
+ i_exception.what();
}
}
catch (const std::exception& l_ex)
diff --git a/vpd-manager/src/worker.cpp b/vpd-manager/src/worker.cpp
index b8b5d2c..d533017 100644
--- a/vpd-manager/src/worker.cpp
+++ b/vpd-manager/src/worker.cpp
@@ -1329,6 +1329,10 @@
}
catch (std::exception& l_ex)
{
+ std::string l_exMsg{
+ std::string(__FUNCTION__) + " : VPD parsing failed for " +
+ i_vpdFilePath + " due to error: " + l_ex.what()};
+
// If post fail action is required, execute it.
if (jsonUtility::isActionRequired(m_parsedJson, i_vpdFilePath,
"postFailAction", "collection"))
@@ -1336,16 +1340,20 @@
if (!jsonUtility::executePostFailAction(m_parsedJson, i_vpdFilePath,
"collection"))
{
- throw std::runtime_error(
- std::string(__FUNCTION__) + "VPD parsing failed for " +
- i_vpdFilePath + " due to error: " + l_ex.what() +
- ". Post Fail Action also failed, aborting collection for this FRU");
+ l_exMsg +=
+ ". Post Fail Action also failed, aborting collection for this FRU";
}
}
- throw std::runtime_error(
- std::string(__FUNCTION__) + "VPD parsing failed for " +
- i_vpdFilePath + " due to error: " + l_ex.what());
+ if (typeid(l_ex) == typeid(DataException))
+ {
+ throw DataException(l_exMsg);
+ }
+ else if (typeid(l_ex) == typeid(EccException))
+ {
+ throw EccException(l_exMsg);
+ }
+ throw std::runtime_error(l_exMsg);
}
}
@@ -1431,7 +1439,11 @@
}
EventLogger::createSyncPel(
- EventLogger::getErrorType(ex), types::SeverityType::Informational,
+ EventLogger::getErrorType(ex),
+ (typeid(ex) == typeid(DataException)) ||
+ (typeid(ex) == typeid(EccException))
+ ? types::SeverityType::Warning
+ : types::SeverityType::Informational,
__FILE__, __FUNCTION__, 0, EventLogger::getErrorMsg(ex),
std::nullopt, std::nullopt, std::nullopt, std::nullopt);