Refactor exception handling for json_utility APIs
This commit adds code to handle exceptions for some of the json_utility
APIs. Each API will have output returned in case of error based on the
return type of the API instead of throwing an exception.
Also updated the caller of the json_utility APIs to handle the return
value.
Change-Id: I154a90d5edbbca7441f75a153b908914de83471d
Signed-off-by: RekhaAparna01 <vrekhaaparna@ibm.com>
diff --git a/vpd-manager/src/gpio_monitor.cpp b/vpd-manager/src/gpio_monitor.cpp
index 2391ad6..2b02c9d 100644
--- a/vpd-manager/src/gpio_monitor.cpp
+++ b/vpd-manager/src/gpio_monitor.cpp
@@ -109,24 +109,16 @@
const std::shared_ptr<boost::asio::io_context>& i_ioContext,
const std::shared_ptr<Worker>& i_worker)
{
- try
- {
- std::vector<std::string> l_gpioPollingRequiredFrusList =
- jsonUtility::getListOfGpioPollingFrus(m_sysCfgJsonObj);
+ std::vector<std::string> l_gpioPollingRequiredFrusList =
+ jsonUtility::getListOfGpioPollingFrus(m_sysCfgJsonObj);
- for (const auto& l_fruPath : l_gpioPollingRequiredFrusList)
- {
- std::shared_ptr<GpioEventHandler> l_gpioEventHandlerObj =
- std::make_shared<GpioEventHandler>(l_fruPath, i_worker,
- i_ioContext);
-
- m_gpioEventHandlerObjects.push_back(l_gpioEventHandlerObj);
- }
- }
- catch (std::exception& l_ex)
+ for (const auto& l_fruPath : l_gpioPollingRequiredFrusList)
{
- // TODO log PEL for exception.
- logging::logMessage(l_ex.what());
+ std::shared_ptr<GpioEventHandler> l_gpioEventHandlerObj =
+ std::make_shared<GpioEventHandler>(l_fruPath, i_worker,
+ i_ioContext);
+
+ m_gpioEventHandlerObjects.push_back(l_gpioEventHandlerObj);
}
}
} // namespace vpd
diff --git a/vpd-manager/src/manager.cpp b/vpd-manager/src/manager.cpp
index 437fdd9..7421ac6 100644
--- a/vpd-manager/src/manager.cpp
+++ b/vpd-manager/src/manager.cpp
@@ -513,18 +513,8 @@
// Get the EEPROM path
if (!l_sysCfgJsonObj.empty())
{
- try
- {
- l_fruPath =
- jsonUtility::getFruPathFromJson(l_sysCfgJsonObj, i_vpdPath);
- }
- catch (const std::exception& l_exception)
- {
- logging::logMessage(
- "Error while getting FRU path, Path: " + i_vpdPath +
- ", error: " + std::string(l_exception.what()));
- return -1;
- }
+ l_fruPath =
+ jsonUtility::getFruPathFromJson(l_sysCfgJsonObj, i_vpdPath);
}
}