diff options
author | Matthew Barth <msbarth@us.ibm.com> | 2017-02-22 11:15:56 -0600 |
---|---|---|
committer | Matthew Barth <msbarth@us.ibm.com> | 2017-03-15 13:46:31 -0500 |
commit | fefdc45eec58f4c6c75d05b156df2dfbae421cd3 (patch) | |
tree | 8b32b7ca51fed3e1aeffd4cbc411b483f45e1e24 | |
parent | 398257a1d26c3591f534168900c271d9541bc4ad (diff) | |
download | phosphor-fan-presence-fefdc45eec58f4c6c75d05b156df2dfbae421cd3.tar.gz phosphor-fan-presence-fefdc45eec58f4c6c75d05b156df2dfbae421cd3.zip |
Trace mapper and inventory errors
Add journal error entries for error conditions on mapper and inventory
manager update calls.
Change-Id: Iecb310575414878f4b83c24136e6ae1312c6f7aa
Signed-off-by: Matthew Barth <msbarth@us.ibm.com>
-rw-r--r-- | Makefile.am | 6 | ||||
-rw-r--r-- | configure.ac | 2 | ||||
-rw-r--r-- | fan_enclosure.cpp | 24 |
3 files changed, 26 insertions, 6 deletions
diff --git a/Makefile.am b/Makefile.am index e6df71c..610e543 100644 --- a/Makefile.am +++ b/Makefile.am @@ -10,8 +10,10 @@ phosphor_fan_presence_tach_SOURCES = \ nodist_phosphor_fan_presence_tach_SOURCES = \ fan_detect_defs.cpp -phosphor_fan_presence_tach_LDFLAGS = $(SDBUSPLUS_LIBS) -phosphor_fan_presence_tach_CXXFLAGS = $(SDBUSPLUS_CFLAGS) +phosphor_fan_presence_tach_LDFLAGS = $(SDBUSPLUS_LIBS) $(PHOSPHOR_LOGGING_LIBS) +phosphor_fan_presence_tach_CXXFLAGS = \ + $(SDBUSPLUS_CFLAGS) \ + $(PHOSPHOR_LOGGING_CFLAGS) BUILT_SOURCES = fan_detect_defs.cpp CLEANFILES = fan_detect_defs.cpp diff --git a/configure.ac b/configure.ac index 648d018..d5659f3 100644 --- a/configure.ac +++ b/configure.ac @@ -23,6 +23,8 @@ AX_APPEND_COMPILE_FLAGS([-Wall -Werror], [CXXFLAGS]) # Checks for libraries. PKG_CHECK_MODULES([SDBUSPLUS], [sdbusplus], , [AC_MSG_ERROR([The openbmc/sdbusplus package is required])]) +PKG_CHECK_MODULES([PHOSPHOR_LOGGING], [phosphor-logging], , +[AC_MSG_ERROR([The openbmc/phosphor-logging package is required])]) # Checks for header files. 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; } } |