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/bios_handler.cpp b/vpd-manager/src/bios_handler.cpp
index 59094e0..65e0c47 100644
--- a/vpd-manager/src/bios_handler.cpp
+++ b/vpd-manager/src/bios_handler.cpp
@@ -290,19 +290,14 @@
             "xyz.openbmc_project.BIOSConfig.Manager.AttributeType.Integer",
             i_fcoVal.at(constants::VALUE_3))));
 
-    try
-    {
-        dbusUtility::writeDbusProperty(
+    if (!dbusUtility::writeDbusProperty(
             constants::biosConfigMgrService, constants::biosConfigMgrObjPath,
             constants::biosConfigMgrInterface, "PendingAttributes",
-            l_pendingBiosAttribute);
-    }
-    catch (const std::exception& l_ex)
+            l_pendingBiosAttribute))
     {
         // TODO: Should we log informational PEL here as well?
         logging::logMessage(
-            "DBus call to update FCO value in pending attribute failed. " +
-            std::string(l_ex.what()));
+            "DBus call to update FCO value in pending attribute failed. ");
     }
 }
 
@@ -370,19 +365,14 @@
             "xyz.openbmc_project.BIOSConfig.Manager.AttributeType.Enumeration",
             l_valtoUpdate)));
 
-    try
-    {
-        dbusUtility::writeDbusProperty(
+    if (!dbusUtility::writeDbusProperty(
             constants::biosConfigMgrService, constants::biosConfigMgrObjPath,
             constants::biosConfigMgrInterface, "PendingAttributes",
-            l_pendingBiosAttribute);
-    }
-    catch (const std::exception& l_ex)
+            l_pendingBiosAttribute))
     {
         // TODO: Should we log informational PEL here as well?
         logging::logMessage(
-            "DBus call to update AMM value in pending attribute failed. " +
-            std::string(l_ex.what()));
+            "DBus call to update AMM value in pending attribute failed.");
     }
 }
 
@@ -505,18 +495,13 @@
             "xyz.openbmc_project.BIOSConfig.Manager.AttributeType.Enumeration",
             l_valtoUpdate)));
 
-    try
-    {
-        dbusUtility::writeDbusProperty(
+    if (!dbusUtility::writeDbusProperty(
             constants::biosConfigMgrService, constants::biosConfigMgrObjPath,
             constants::biosConfigMgrInterface, "PendingAttributes",
-            l_pendingBiosAttribute);
-    }
-    catch (const std::exception& l_ex)
+            l_pendingBiosAttribute))
     {
         logging::logMessage(
-            "DBus call to update lpar value in pending attribute failed. " +
-            std::string(l_ex.what()));
+            "DBus call to update lpar value in pending attribute failed.");
     }
 
     return;
@@ -621,18 +606,13 @@
             "xyz.openbmc_project.BIOSConfig.Manager.AttributeType.Enumeration",
             l_valtoUpdate)));
 
-    try
-    {
-        dbusUtility::writeDbusProperty(
+    if (!dbusUtility::writeDbusProperty(
             constants::biosConfigMgrService, constants::biosConfigMgrObjPath,
             constants::biosConfigMgrInterface, "PendingAttributes",
-            l_pendingBiosAttribute);
-    }
-    catch (const std::exception& l_ex)
+            l_pendingBiosAttribute))
     {
         logging::logMessage(
-            "DBus call to update NVRAM value in pending attribute failed. " +
-            std::string(l_ex.what()));
+            "DBus call to update NVRAM value in pending attribute failed.");
     }
 }
 
@@ -732,18 +712,13 @@
             "xyz.openbmc_project.BIOSConfig.Manager.AttributeType.Enumeration",
             l_valtoUpdate)));
 
-    try
-    {
-        dbusUtility::writeDbusProperty(
+    if (!dbusUtility::writeDbusProperty(
             constants::biosConfigMgrService, constants::biosConfigMgrObjPath,
             constants::biosConfigMgrInterface, "PendingAttributes",
-            l_pendingBiosAttribute);
-    }
-    catch (const std::exception& l_ex)
+            l_pendingBiosAttribute))
     {
         logging::logMessage(
-            "DBus call to update keep and clear value in pending attribute failed. " +
-            std::string(l_ex.what()));
+            "DBus call to update keep and clear value in pending attribute failed.");
     }
 }