Update to allow missing inventory property
On startup, there is a chance that the inventory property may not be
populated.
Change-Id: Ie364a3dc5b7f19cbc587450fc54f231d1ec280f7
Signed-off-by: Brandon Wyman <bjwyman@gmail.com>
diff --git a/power-supply/power_supply.cpp b/power-supply/power_supply.cpp
index f5d3fa3..38eddf6 100644
--- a/power-supply/power_supply.cpp
+++ b/power-supply/power_supply.cpp
@@ -180,8 +180,20 @@
// Use getProperty utility function to get presence status.
std::string path = INVENTORY_OBJ_PATH + inventoryPath;
std::string service = "xyz.openbmc_project.Inventory.Manager";
- util::getProperty(INVENTORY_INTERFACE, PRESENT_PROP, path,
- service, bus, this->present);
+
+ try
+ {
+ util::getProperty(INVENTORY_INTERFACE, PRESENT_PROP, path,
+ service, bus, this->present);
+ }
+ catch (std::exception& e)
+ {
+ // If we happen to be trying to update presence just as it is being
+ // updated, we may encounter a runtime_error. Just catch that for
+ // now, let the inventoryChanged signal handler update presence later.
+ present = false;
+ }
+
}
void PowerSupply::clearFaults()