pldm_fru: Handle scenario when config JSON is missing

PLDM daemon will throw an InternalFailure exception if the PLDM FRU
JSON config directory is missing and will crash. This is relaxed and
the FRU commands will gracefully handle when FRU table does not exist.

Tested:

On Rainier the pldm daemon is started after removing the
/usr/share/pldm/fru directory and GetFRURecordTableMetadata and
GetFRURecordTable commands were executed using pldmtool.

1) GetFRURecordTableMetadata

pldmtool raw -d 0x80 0x04 0x01
Response Message:
08 01 00 04 01 00 01 00 ff ff ff ff 00 00 00 00 00 00 00 00 00 00 00 00

2) GetFRURecordTable
pldmtool raw -d 0x80 0x04 0x02 0x00 0x00 0x00 0x00 0x00
Response Message:
08 01 00 04 02 00 00 00 00 00 05 00 00 00 00

Change-Id: I879a812abec8b1dc9c3ec7fa423ce3b3188d74b2
Signed-off-by: Tom Joseph <tomjoseph@in.ibm.com>
diff --git a/libpldmresponder/fru.cpp b/libpldmresponder/fru.cpp
index 01afde3..23dd9fa 100644
--- a/libpldmresponder/fru.cpp
+++ b/libpldmresponder/fru.cpp
@@ -19,14 +19,14 @@
 {
     fru_parser::FruParser handle(configPath);
 
-    auto dbusInfo = handle.inventoryLookup();
-
+    fru_parser::DBusLookupInfo dbusInfo;
     // Read the all the inventory D-Bus objects
     auto& bus = pldm::utils::DBusHandler::getBus();
     dbus::ObjectValueTree objects;
 
     try
     {
+        dbusInfo = handle.inventoryLookup();
         auto method = bus.new_method_call(
             std::get<0>(dbusInfo).c_str(), std::get<1>(dbusInfo).c_str(),
             "org.freedesktop.DBus.ObjectManager", "GetManagedObjects");
diff --git a/libpldmresponder/fru_parser.cpp b/libpldmresponder/fru_parser.cpp
index b8bb01b..a63dae6 100644
--- a/libpldmresponder/fru_parser.cpp
+++ b/libpldmresponder/fru_parser.cpp
@@ -31,15 +31,15 @@
     if (!fs::exists(dir) || fs::is_empty(dir))
     {
         std::cerr << "FRU config directory does not exist or empty, DIR="
-                  << dirPath;
-        throw InternalFailure();
+                  << dirPath << "\n";
+        return;
     }
 
     fs::path masterFilePath = dir / fruMasterJson;
     if (!fs::exists(masterFilePath))
     {
         std::cerr << "FRU D-Bus lookup JSON does not exist, PATH="
-                  << masterFilePath;
+                  << masterFilePath << "\n";
         throw InternalFailure();
     }
 
diff --git a/test/libpldmresponder_fru_test.cpp b/test/libpldmresponder_fru_test.cpp
index 6a0dbbb..9e66ea2 100644
--- a/test/libpldmresponder_fru_test.cpp
+++ b/test/libpldmresponder_fru_test.cpp
@@ -6,8 +6,6 @@
 {
     using namespace pldm::responder::fru_parser;
 
-    // Empty directory condition
-    ASSERT_THROW(FruParser("./fru_json"), std::exception);
     // No master FRU JSON
     ASSERT_THROW(FruParser("./fru_jsons/malformed1"), std::exception);
     // Malformed master FRU JSON