summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Makefile.am6
-rw-r--r--configure.ac2
-rw-r--r--fan_enclosure.cpp24
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;
}
}
OpenPOWER on IntegriCloud