summaryrefslogtreecommitdiffstats
path: root/cooling-type/cooling_type.cpp
diff options
context:
space:
mode:
authorDinesh Chinari <chinari@us.ibm.com>2017-06-26 23:26:50 -0500
committerDinesh Chinari <chinari@us.ibm.com>2017-06-28 08:16:18 -0500
commit618027abcf491b0b58f71bfe2b48c55dfb86462e (patch)
tree358d628f65ba2b426210d837681baa287b869603 /cooling-type/cooling_type.cpp
parentbb12c926dca2215bccfbd270da11f0c2b5822878 (diff)
downloadphosphor-fan-presence-618027abcf491b0b58f71bfe2b48c55dfb86462e.tar.gz
phosphor-fan-presence-618027abcf491b0b58f71bfe2b48c55dfb86462e.zip
phosphor-fan-presence elog error exception.
Implemented elog exception for phosphor fan presence, replacing runtime_errors. Change-Id: I70465060838b2cbaeadccf84ed5924e222ac59e3 Signed-off-by: Dinesh Chinari <chinari@us.ibm.com>
Diffstat (limited to 'cooling-type/cooling_type.cpp')
-rw-r--r--cooling-type/cooling_type.cpp25
1 files changed, 16 insertions, 9 deletions
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 <unistd.h>
#include <sdbusplus/bus.hpp>
#include <phosphor-logging/log.hpp>
+#include <phosphor-logging/elog.hpp>
+#include <phosphor-logging/elog-errors.hpp>
+#include <xyz/openbmc_project/Common/error.hpp>
#include <libevdev/libevdev.h>
#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<libevdev, FreeEvDev> evdevOpen(int fd)
{
libevdev* gpioDev = nullptr;
@@ -23,10 +31,9 @@ std::unique_ptr<libevdev, FreeEvDev> 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<level::ERR>("Failed to get libevdev from file descriptor",
+ entry("RC=%d", rc));
+ elog<InternalFailure>();
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<level::ERR>("Device does not support event type",
+ entry("KEYCODE=%d", keycode));
+ elog<InternalFailure>();
}
// 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<level::ERR>(
"Error in inventory manager call to update inventory");
+ elog<InternalFailure>();
}
}
OpenPOWER on IntegriCloud