Log PEL if back up and restore class fails
Log PEL and continue with Manager class instantiation if back up and
restore class fails as Manager should continue with rest of the
functionalities even when back up and restore fails.
Change-Id: If40ffb577a90655b442a0bd83b72f75a28f0927a
Signed-off-by: Sunny Srivastava <sunnsr25@in.ibm.com>
diff --git a/vpd-manager/src/manager.cpp b/vpd-manager/src/manager.cpp
index 09d8b85..0df9f80 100644
--- a/vpd-manager/src/manager.cpp
+++ b/vpd-manager/src/manager.cpp
@@ -64,8 +64,23 @@
if (!m_worker->getSysCfgJsonObj().empty() &&
jsonUtility::isBackupAndRestoreRequired(l_sysCfgJsonObj))
{
- m_backupAndRestoreObj =
- std::make_shared<BackupAndRestore>(l_sysCfgJsonObj);
+ try
+ {
+ m_backupAndRestoreObj =
+ std::make_shared<BackupAndRestore>(l_sysCfgJsonObj);
+ }
+ catch (const std::exception& l_ex)
+ {
+ logging::logMessage(
+ "Back up and restore instantiation failed. {" +
+ std::string(l_ex.what()) + "}");
+
+ EventLogger::createSyncPel(
+ EventLogger::getErrorType(l_ex),
+ types::SeverityType::Warning, __FILE__, __FUNCTION__, 0,
+ EventLogger::getErrorMsg(l_ex), std::nullopt, std::nullopt,
+ std::nullopt, std::nullopt);
+ }
}
// set callback to detect any asset tag change