diff options
Diffstat (limited to 'fan_enclosure.cpp')
-rw-r--r-- | fan_enclosure.cpp | 24 |
1 files changed, 20 insertions, 4 deletions
diff --git a/fan_enclosure.cpp b/fan_enclosure.cpp index b2ea9f7..998bd50 100644 --- a/fan_enclosure.cpp +++ b/fan_enclosure.cpp @@ -1,4 +1,5 @@ #include <algorithm> +#include <phosphor-logging/log.hpp> #include "fan_enclosure.hpp" @@ -9,6 +10,8 @@ namespace fan namespace presence { +using namespace phosphor::logging; + //TODO Should get these from phosphor-objmgr config.h constexpr auto MAPPER_BUSNAME = "xyz.openbmc_project.ObjectMapper"; constexpr auto MAPPER_PATH = "/xyz/openbmc_project/ObjectMapper"; @@ -50,7 +53,8 @@ std::string FanEnclosure::getInvService() auto mapperResponseMsg = bus.call(mapperCall); if (mapperResponseMsg.is_method_error()) { - //TODO Retry or throw exception/log error? + throw std::runtime_error( + "Error in mapper call to get inventory service name"); } std::map<std::string, std::vector<std::string>> mapperResponse; @@ -58,7 +62,8 @@ std::string FanEnclosure::getInvService() if (mapperResponse.empty()) { - //TODO Nothing found, throw exception/log error? + throw std::runtime_error( + "Error in mapper response for inventory service name"); } return mapperResponse.begin()->first; @@ -69,7 +74,16 @@ void FanEnclosure::updInventory() //Get inventory object for this fan ObjectMap invObj = getObjectMap(); //Get inventory manager service name from mapper - std::string invService = getInvService(); + std::string invService; + try + { + invService = getInvService(); + } + catch (const std::runtime_error& err) + { + log<level::ERR>(err.what()); + return; + } // Update inventory for this fan auto invMsg = bus.new_method_call(invService.c_str(), INVENTORY_PATH, @@ -79,7 +93,9 @@ void FanEnclosure::updInventory() auto invMgrResponseMsg = bus.call(invMsg); if (invMgrResponseMsg.is_method_error()) { - //TODO Handle error in notify call + log<level::ERR>( + "Error in inventory manager call to update inventory"); + return; } } |