Refactor exception handling for writeDbusProperty API
This commit refactors dbus_utility API used to update property value on
DBus to handle any exceptions thrown by it locally and return only
success or failure as the return type.
Also updated the caller of this API to handle the return value.
Change-Id: Ia92c1b0928d02cc0130a8b4e547ba3c6069d0d2f
Signed-off-by: RekhaAparna01 <vrekhaaparna@ibm.com>
diff --git a/vpd-manager/src/worker.cpp b/vpd-manager/src/worker.cpp
index 4199c15..1529924 100644
--- a/vpd-manager/src/worker.cpp
+++ b/vpd-manager/src/worker.cpp
@@ -1462,19 +1462,15 @@
if (!l_inventoryPath.empty())
{
- try
- {
- dbusUtility::writeDbusProperty(
+ if (!dbusUtility::writeDbusProperty(
jsonUtility::getServiceName(m_parsedJson, l_inventoryPath),
l_inventoryPath, constants::vpdCollectionInterface,
"CollectionStatus",
- types::DbusVariantType{constants::vpdCollectionInProgress});
- }
- catch (const std::exception& l_exception)
+ types::DbusVariantType{constants::vpdCollectionInProgress}))
{
logging::logMessage(
"Unable to set CollectionStatus as InProgress for " +
- i_vpdFilePath + ". Error : " + l_exception.what());
+ i_vpdFilePath + ". Error : " + "DBus write failed");
}
}