From 618027abcf491b0b58f71bfe2b48c55dfb86462e Mon Sep 17 00:00:00 2001 From: Dinesh Chinari Date: Mon, 26 Jun 2017 23:26:50 -0500 Subject: phosphor-fan-presence elog error exception. Implemented elog exception for phosphor fan presence, replacing runtime_errors. Change-Id: I70465060838b2cbaeadccf84ed5924e222ac59e3 Signed-off-by: Dinesh Chinari --- cooling-type/Makefile.am | 6 ++++-- cooling-type/cooling_type.cpp | 25 ++++++++++++++++--------- 2 files changed, 20 insertions(+), 11 deletions(-) (limited to 'cooling-type') diff --git a/cooling-type/Makefile.am b/cooling-type/Makefile.am index b18b2d6..869d463 100644 --- a/cooling-type/Makefile.am +++ b/cooling-type/Makefile.am @@ -12,12 +12,14 @@ phosphor_cooling_type_SOURCES = \ phosphor_cooling_type_CXXFLAGS = \ $(SDBUSPLUS_CFLAGS) \ $(PHOSPHOR_LOGGING_CFLAGS) \ - $(LIBEVDEV_CFLAGS) + $(LIBEVDEV_CFLAGS) \ + ${PHOSPHOR_DBUS_INTERFACES_CFLAGS} phosphor_cooling_type_LDADD = \ ${top_builddir}/libfan.la \ $(SDBUSPLUS_LIBS) \ $(PHOSPHOR_LOGGING_LIBS) \ - $(LIBEVDEV_LIBS) + $(LIBEVDEV_LIBS) \ + ${PHOSPHOR_DBUS_INTERFACES_LIBS} # vim: tabstop=8 noexpandtab diff --git a/cooling-type/cooling_type.cpp b/cooling-type/cooling_type.cpp index eb4a449..c1f96aa 100644 --- a/cooling-type/cooling_type.cpp +++ b/cooling-type/cooling_type.cpp @@ -2,6 +2,9 @@ #include #include #include +#include +#include +#include #include #include "utility.hpp" #include "cooling_type.hpp" @@ -13,6 +16,11 @@ namespace cooling namespace type { +// For throwing exception +using namespace phosphor::logging; +using InternalFailure = sdbusplus::xyz::openbmc_project::Common:: + Error::InternalFailure; + std::unique_ptr evdevOpen(int fd) { libevdev* gpioDev = nullptr; @@ -23,10 +31,9 @@ std::unique_ptr evdevOpen(int fd) return decltype(evdevOpen(0))(gpioDev); } - //TODO - Create error log for failure. openbmc/openbmc#1542 - throw std::runtime_error("Failed to get libevdev from file descriptor" - " rc = " + std::to_string(rc)); - + log("Failed to get libevdev from file descriptor", + entry("RC=%d", rc)); + elog(); return decltype(evdevOpen(0))(nullptr); } @@ -53,10 +60,9 @@ void CoolingType::readGpio(const std::string& gpioPath, unsigned int keycode) keycode, &value); if (0 == fetch_rc) { - //TODO - Create error log for failure. openbmc/openbmc#1542 - throw std::runtime_error( - "Device does not support event type=EV_KEY and code=" + - std::to_string(keycode)); + log("Device does not support event type", + entry("KEYCODE=%d", keycode)); + elog(); } // TODO openbmc/phosphor-fan-presence#6 @@ -105,8 +111,9 @@ void CoolingType::updateInventory(const std::string& objpath) auto invMgrResponseMsg = bus.call(invMsg); if (invMgrResponseMsg.is_method_error()) { - throw std::runtime_error( + log( "Error in inventory manager call to update inventory"); + elog(); } } -- cgit v1.2.1