Update error handling in main file
Main file need not handle each exception separately. Instead a common
PEL needs to be logged based on the type of exception received with
critical severity as the service failed to start.
Change-Id: Ic432a2ab2caf6dac70c376219fce6597e7782309
Signed-off-by: Sunny Srivastava <sunnsr25@in.ibm.com>
diff --git a/vpd-manager/src/manager_main.cpp b/vpd-manager/src/manager_main.cpp
index a1d61e4..7384d25 100644
--- a/vpd-manager/src/manager_main.cpp
+++ b/vpd-manager/src/manager_main.cpp
@@ -49,46 +49,12 @@
}
catch (const std::exception& l_ex)
{
- if (typeid(l_ex) == typeid(vpd::JsonException))
- {
- // ToDo: Severity needs to be revisited.
- vpd::EventLogger::createAsyncPel(
- vpd::types::ErrorType::JsonFailure,
- vpd::types::SeverityType::Informational, __FILE__, __FUNCTION__,
- 0,
- std::string("VPD Manager service failed with : ") + l_ex.what(),
- std::nullopt, std::nullopt, std::nullopt, std::nullopt);
- }
- else if (typeid(l_ex) == typeid(vpd::GpioException))
- {
- // ToDo: Severity needs to be revisited.
- vpd::EventLogger::createAsyncPel(
- vpd::types::ErrorType::GpioError,
- vpd::types::SeverityType::Informational, __FILE__, __FUNCTION__,
- 0,
- std::string("VPD Manager service failed with : ") + l_ex.what(),
- std::nullopt, std::nullopt, std::nullopt, std::nullopt);
- }
- else if (typeid(l_ex) == typeid(sdbusplus::exception::SdBusError))
- {
- // ToDo: Severity needs to be revisited.
- vpd::EventLogger::createAsyncPel(
- vpd::types::ErrorType::DbusFailure,
- vpd::types::SeverityType::Informational, __FILE__, __FUNCTION__,
- 0,
- std::string("VPD Manager service failed with : ") + l_ex.what(),
- std::nullopt, std::nullopt, std::nullopt, std::nullopt);
- }
- else
- {
- // ToDo: Severity needs to be revisited.
- vpd::EventLogger::createAsyncPel(
- vpd::types::ErrorType::InvalidVpdMessage,
- vpd::types::SeverityType::Informational, __FILE__, __FUNCTION__,
- 0,
- std::string("VPD Manager service failed with : ") + l_ex.what(),
- "BMC0001", std::nullopt, std::nullopt, std::nullopt);
- }
+ vpd::logging::logMessage("VPD-Manager service failed to start.");
+ vpd::EventLogger::createAsyncPel(
+ vpd::EventLogger::getErrorType(l_ex),
+ vpd::types::SeverityType::Critical, __FILE__, __FUNCTION__, 0,
+ vpd::EventLogger::getErrorMsg(l_ex), std::nullopt, std::nullopt,
+ std::nullopt, std::nullopt);
}
exit(EXIT_FAILURE);
}