From fefdc45eec58f4c6c75d05b156df2dfbae421cd3 Mon Sep 17 00:00:00 2001 From: Matthew Barth Date: Wed, 22 Feb 2017 11:15:56 -0600 Subject: 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 --- Makefile.am | 6 ++++-- configure.ac | 2 ++ 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 +#include #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> 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(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( + "Error in inventory manager call to update inventory"); + return; } } -- cgit v1.2.1