pldmd: fix crash when re-request D-Bus name

`bus.request_name("xyz.openbmc_project.PLDM")` throws D-Bus exception
when the name `xyz.openbmc_project.PLDM` is already requested. This
causes the `pldmd` service will be crashed when build pldm source with
`oem-ibm` disabled & `system-specific-bios-json` disabled. Add
`try...catch...` to prevent the crash of `pldmd`.

Tested:
Was able to successfully start pldm service and see that the bus name
`xyz.openbmc_project.PLDM` was claimed with these options setups:
+ `oem-ibm` disabled & `system-specific-bios-json` enabled.
+ `oem-ibm` disabled & `system-specific-bios-json` disabled.

Signed-off-by: Thu Nguyen <thu@os.amperecomputing.com>
Change-Id: I2ac70b686d1468b9c7484d5bf2543db2b4f33ded
diff --git a/pldmd/pldmd.cpp b/pldmd/pldmd.cpp
index 9613e02..8695fe8 100644
--- a/pldmd/pldmd.cpp
+++ b/pldmd/pldmd.cpp
@@ -65,6 +65,7 @@
 #endif
 
 constexpr uint8_t MCTP_MSG_TYPE_PLDM = 1;
+constexpr const char* PLDMService = "xyz.openbmc_project.PLDM";
 
 using namespace pldm;
 using namespace sdeventplus;
@@ -84,8 +85,16 @@
 
 void requestPLDMServiceName()
 {
-    auto& bus = pldm::utils::DBusHandler::getBus();
-    bus.request_name("xyz.openbmc_project.PLDM");
+    try
+    {
+        auto& bus = pldm::utils::DBusHandler::getBus();
+        bus.request_name(PLDMService);
+    }
+    catch (const sdbusplus::exception_t& e)
+    {
+        error("Failed to request D-Bus name {NAME} with error {ERROR}.", "NAME",
+              PLDMService, "ERROR", e);
+    }
 }
 
 static std::optional<Response>
@@ -371,7 +380,15 @@
 
     bus.attach_event(event.get(), SD_EVENT_PRIORITY_NORMAL);
 #ifndef SYSTEM_SPECIFIC_BIOS_JSON
-    bus.request_name("xyz.openbmc_project.PLDM");
+    try
+    {
+        bus.request_name(PLDMService);
+    }
+    catch (const sdbusplus::exception_t& e)
+    {
+        error("Failed to request D-Bus name {NAME} with error {ERROR}.", "NAME",
+              PLDMService, "ERROR", e);
+    }
 #endif
     IO io(event, pldmTransport.getEventSource(), EPOLLIN, std::move(callback));
 #ifdef LIBPLDMRESPONDER