Skip to content

Commit ec70b75

Browse files
Handling of PELs while system VPD collection
The commit updates handling of PEL in the path of system VPD collection. In case of any error, manager service will not fail. Signed-off-by: Sunny Srivastava <[email protected]>
1 parent 676ae9e commit ec70b75

File tree

1 file changed

+30
-63
lines changed

1 file changed

+30
-63
lines changed

vpd-manager/src/worker.cpp

Lines changed: 30 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -146,23 +146,38 @@ void Worker::performInitialSetup()
146146
// some reason at system power on.
147147
return;
148148
}
149-
catch (const std::exception& ex)
149+
catch (const std::exception& l_ex)
150150
{
151-
if (typeid(ex) == std::type_index(typeid(DataException)))
151+
// Any issue is system inital set up is handled in this catch. Service
152+
// is not blocked for these errors.
153+
154+
types::ErrorType l_errType = types::ErrorType::InvalidSystem;
155+
types::SeverityType l_sevType = types::SeverityType::Critical;
156+
std::string l_errMsg;
157+
158+
if (typeid(l_ex) == std::type_index(typeid(DataException)))
152159
{
153-
// TODO:Catch logic to be implemented once PEL code goes in.
160+
l_errType = types::ErrorType::InvalidVpdMessage;
161+
l_errMsg =
162+
"Data Exception occurred for system VPD file path with error = ";
154163
}
155-
else if (typeid(ex) == std::type_index(typeid(EccException)))
164+
else if (typeid(l_ex) == std::type_index(typeid(EccException)))
156165
{
157-
// TODO:Catch logic to be implemented once PEL code goes in.
166+
l_errType = types::ErrorType::EccCheckFailed;
167+
l_errMsg =
168+
"ECC Exception occurred for system VPD file path with error = ";
158169
}
159-
else if (typeid(ex) == std::type_index(typeid(JsonException)))
170+
else if (typeid(l_ex) == std::type_index(typeid(JsonException)))
160171
{
161-
// TODO:Catch logic to be implemented once PEL code goes in.
172+
l_errType = types::ErrorType::JsonFailure;
173+
l_errMsg =
174+
"Json Exception occurred for system VPD file path with error = " +
175+
;
162176
}
163177

164-
logging::logMessage(ex.what());
165-
throw;
178+
EventLogger::createSyncPel(l_errType, l_sevType, __FILE__, __FUNCTION__,
179+
0, l_errMsg + l_ex.what(), std::nullopt,
180+
std::nullopt, std::nullopt, std::nullopt);
166181
}
167182
}
168183
#endif
@@ -302,57 +317,9 @@ void Worker::fillVPDMap(const std::string& vpdFilePath,
302317
throw std::runtime_error("Can't Find physical file");
303318
}
304319

305-
try
306-
{
307-
std::shared_ptr<Parser> vpdParser =
308-
std::make_shared<Parser>(vpdFilePath, m_parsedJson);
309-
vpdMap = vpdParser->parse();
310-
}
311-
catch (const std::exception& ex)
312-
{
313-
if (typeid(ex) == std::type_index(typeid(DataException)))
314-
{
315-
// TODO: Do what needs to be done in case of Data exception.
316-
// Uncomment when PEL implementation goes in.
317-
/* string errorMsg =
318-
"VPD file is either empty or invalid. Parser failed for [";
319-
errorMsg += m_vpdFilePath;
320-
errorMsg += "], with error = " + std::string(ex.what());
321-
322-
additionalData.emplace("DESCRIPTION", errorMsg);
323-
additionalData.emplace("CALLOUT_INVENTORY_PATH",
324-
INVENTORY_PATH + baseFruInventoryPath);
325-
createPEL(additionalData, pelSeverity, errIntfForInvalidVPD,
326-
nullptr);*/
327-
328-
// throw generic error from here to inform main caller about
329-
// failure.
330-
logging::logMessage(ex.what());
331-
throw std::runtime_error(
332-
"Data Exception occurred for file path = " + vpdFilePath);
333-
}
334-
335-
if (typeid(ex) == std::type_index(typeid(EccException)))
336-
{
337-
// TODO: Do what needs to be done in case of ECC exception.
338-
// Uncomment when PEL implementation goes in.
339-
/* additionalData.emplace("DESCRIPTION", "ECC check failed");
340-
additionalData.emplace("CALLOUT_INVENTORY_PATH",
341-
INVENTORY_PATH + baseFruInventoryPath);
342-
createPEL(additionalData, pelSeverity, errIntfForEccCheckFail,
343-
nullptr);
344-
*/
345-
346-
logging::logMessage(ex.what());
347-
// Need to decide once all error handling is implemented.
348-
// vpdSpecificUtility::dumpBadVpd(vpdFilePath,vpdVector);
349-
350-
// throw generic error from here to inform main caller about
351-
// failure.
352-
throw std::runtime_error("Ecc Exception occurred for file path = " +
353-
vpdFilePath);
354-
}
355-
}
320+
std::shared_ptr<Parser> vpdParser = std::make_shared<Parser>(vpdFilePath,
321+
m_parsedJson);
322+
vpdMap = vpdParser->parse();
356323
}
357324

358325
void Worker::getSystemJson(std::string& systemJson,
@@ -480,9 +447,9 @@ void Worker::setDeviceTreeAndJson()
480447
// Implies it is default JSON.
481448
std::string systemJson{JSON_ABSOLUTE_PATH_PREFIX};
482449

483-
// ToDo: Need to check if INVENTORY_JSON_SYM_LINK pointing to correct system
484-
// This is required to support movement from rainier to Blue Ridge on the
485-
// fly.
450+
// ToDo: Need to check if INVENTORY_JSON_SYM_LINK pointing to correct
451+
// system This is required to support movement from rainier to Blue
452+
// Ridge on the fly.
486453

487454
// Do we have the entry for device tree in parsed JSON?
488455
if (m_parsedJson.find("devTree") == m_parsedJson.end())

0 commit comments

Comments
 (0)