libpldmresponder: Migrate to pldm_entity_association_pdr_add_check()

pldm_entity_assocation_pdr_add() is deprecated in libpldm as it used
assert() for handling error cases.
pldm_entity_association_pdr_add_check() instead returns a value
indicating success or failure.

We throw a std::runtime_error for now which at least unwinds the stack,
unlike assert(). With this approach the problem is reduced to needing to
refactor internal pldmd APIs, rather than despairing at libpldm aborting
the process out of existence.

Signed-off-by: Andrew Jeffery <andrew@aj.id.au>
Change-Id: I08ebafc94cd7a392ec8f18b6c5feb75ba72cd028
diff --git a/libpldmresponder/fru.cpp b/libpldmresponder/fru.cpp
index 303f413..69ca3cb 100644
--- a/libpldmresponder/fru.cpp
+++ b/libpldmresponder/fru.cpp
@@ -116,8 +116,16 @@
         }
     }
 
-    pldm_entity_association_pdr_add(entityTree, pdrRepo, false,
-                                    TERMINUS_HANDLE);
+    int rc = pldm_entity_association_pdr_add_check(entityTree, pdrRepo, false,
+                                                   TERMINUS_HANDLE);
+    if (rc < 0)
+    {
+        // pldm_entity_assocation_pdr_add() assert()ed on failure
+        error("Failed to add PLDM entity association PDR: {LIBPLDM_ERROR}",
+              "LIBPLDM_ERROR", rc);
+        throw std::runtime_error("Failed to add PLDM entity association PDR");
+    }
+
     // save a copy of bmc's entity association tree
     pldm_entity_association_tree_copy_root(entityTree, bmcEntityTree);