PLDM:Catching exception precisely and printing it

Correcting catch block in PLDM repo to print all
exception precisely so pldm trace can be more
useful to identify defect easily.

Change-Id: If2e86dcb031ddc2e927e7836d7f4359f5b44cdec
Signed-off-by: Kamalkumar Patel <kamalkumar.patel@ibm.com>
diff --git a/oem/ibm/libpldmresponder/file_io.cpp b/oem/ibm/libpldmresponder/file_io.cpp
index b01ef19..bfb2fd1 100644
--- a/oem/ibm/libpldmresponder/file_io.cpp
+++ b/oem/ibm/libpldmresponder/file_io.cpp
@@ -281,9 +281,8 @@
     }
     catch (const std::exception& e)
     {
-        error(
-            "File handle does not exist in the file table, HANDLE={FILE_HANDLE}",
-            "FILE_HANDLE", fileHandle);
+        error("Handle ({HANDLE}) does not exist in the file table: {ERROR}",
+              "HANDLE", fileHandle, "ERROR", e);
         encode_rw_file_memory_resp(request->hdr.instance_id,
                                    PLDM_READ_FILE_INTO_MEMORY,
                                    PLDM_INVALID_FILE_HANDLE, 0, responsePtr);
@@ -376,9 +375,8 @@
     }
     catch (const std::exception& e)
     {
-        error(
-            "File handle does not exist in the file table, HANDLE={FILE_HANDLE}",
-            "FILE_HANDLE", fileHandle);
+        error("Handle ({HANDLE}) does not exist in the file table: {ERROR}",
+              "HANDLE", fileHandle, "ERROR", e);
         encode_rw_file_memory_resp(request->hdr.instance_id,
                                    PLDM_WRITE_FILE_FROM_MEMORY,
                                    PLDM_INVALID_FILE_HANDLE, 0, responsePtr);
@@ -504,9 +502,9 @@
     }
     catch (const std::exception& e)
     {
-        error(
-            "File handle does not exist in the file table, HANDLE={FILE_HANDLE}",
-            "FILE_HANDLE", fileHandle);
+        error("Handle ({HANDLE}) does not exist in the file table: {ERROR}",
+              "HANDLE", fileHandle, "ERROR", e);
+
         encode_read_file_resp(request->hdr.instance_id,
                               PLDM_INVALID_FILE_HANDLE, length, responsePtr);
         return response;
@@ -587,9 +585,8 @@
     }
     catch (const std::exception& e)
     {
-        error(
-            "File handle does not exist in the file table, HANDLE={FILE_HANDLE}",
-            "FILE_HANDLE", fileHandle);
+        error("Handle ({HANDLE}) does not exist in the file table: {ERROR}",
+              "HANDLE", fileHandle, "ERROR", e);
         encode_write_file_resp(request->hdr.instance_id,
                                PLDM_INVALID_FILE_HANDLE, 0, responsePtr);
         return response;
@@ -675,7 +672,8 @@
     }
     catch (const InternalFailure& e)
     {
-        error("unknown file type, TYPE={FILE_TYPE}", "FILE_TYPE", fileType);
+        error("Unknown file type '{FILE_TYPE}': {ERROR} ", "FILE_TYPE",
+              fileType, "ERROR", e);
         encode_rw_file_by_type_memory_resp(request->hdr.instance_id, cmd,
                                            PLDM_INVALID_FILE_TYPE, 0,
                                            responsePtr);
@@ -740,7 +738,8 @@
     }
     catch (const InternalFailure& e)
     {
-        error("unknown file type, TYPE={FILE_TYPE}", "FILE_TYPE", fileType);
+        error("Unknown file type '{FILE_TYPE}': {ERROR}", "FILE_TYPE", fileType,
+              "ERROR", e);
         encode_rw_file_by_type_resp(request->hdr.instance_id,
                                     PLDM_WRITE_FILE_BY_TYPE,
                                     PLDM_INVALID_FILE_TYPE, 0, responsePtr);
@@ -789,7 +788,8 @@
     }
     catch (const InternalFailure& e)
     {
-        error("unknown file type, TYPE={FILE_TYPE}", "FILE_TYPE", fileType);
+        error("Unknown file type '{FILE_TYPE}': {ERROR}", "FILE_TYPE", fileType,
+              "ERROR", e);
         encode_rw_file_by_type_resp(request->hdr.instance_id,
                                     PLDM_READ_FILE_BY_TYPE,
                                     PLDM_INVALID_FILE_TYPE, 0, responsePtr);
@@ -835,6 +835,8 @@
 
     catch (const InternalFailure& e)
     {
+        error("Unknown file type '{FILE_TYPE}': {ERROR}", "FILE_TYPE", fileType,
+              "ERROR", e);
         encode_file_ack_resp(request->hdr.instance_id, PLDM_INVALID_FILE_TYPE,
                              responsePtr);
         return response;
@@ -909,7 +911,8 @@
     }
     catch (const InternalFailure& e)
     {
-        error("unknown file type, TYPE={FILE_TYPE}", "FILE_TYPE", fileType);
+        error("Unknown file type '{FILE_TYPE}': {ERROR}", "FILE_TYPE", fileType,
+              "ERROR", e);
         return CmdHandler::ccOnlyResponse(request, PLDM_INVALID_FILE_TYPE);
     }
 
diff --git a/oem/ibm/libpldmresponder/oem_ibm_handler.cpp b/oem/ibm/libpldmresponder/oem_ibm_handler.cpp
index a910f72..7ab075d 100644
--- a/oem/ibm/libpldmresponder/oem_ibm_handler.cpp
+++ b/oem/ibm/libpldmresponder/oem_ibm_handler.cpp
@@ -513,7 +513,7 @@
         isWatchDogRunning = pldm::utils::DBusHandler().getDbusProperty<bool>(
             watchDogObjectPath, watchDogEnablePropName, watchDogInterface);
     }
-    catch (const std::exception& e)
+    catch (const std::exception&)
     {
         return false;
     }
@@ -591,7 +591,7 @@
     }
     catch (const std::exception& e)
     {
-        error("Error getting the current BMC state");
+        error("Error getting the current BMC state: {ERROR}", "ERROR", e);
         return PLDM_ERROR;
     }
     return PLDM_SUCCESS;
diff --git a/oem/ibm/libpldmresponder/platform_oem_ibm.cpp b/oem/ibm/libpldmresponder/platform_oem_ibm.cpp
index 660b300..432bfd4 100644
--- a/oem/ibm/libpldmresponder/platform_oem_ibm.cpp
+++ b/oem/ibm/libpldmresponder/platform_oem_ibm.cpp
@@ -44,8 +44,7 @@
         }
     }
     catch (
-        const sdbusplus::xyz::openbmc_project::Common::Error::ResourceNotFound&
-            e)
+        const sdbusplus::xyz::openbmc_project::Common::Error::ResourceNotFound&)
     {
         /* Exception is expected to happen in the case when state manager is
          * started after pldm, this is expected to happen in reboot case