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>
diff --git a/utility.hpp b/utility.hpp
index 880545a..32d055e 100644
--- a/utility.hpp
+++ b/utility.hpp
@@ -3,8 +3,16 @@
 #include <sdbusplus/bus.hpp>
 #include <unistd.h>
 #include <fcntl.h>
+#include <phosphor-logging/log.hpp>
+#include <phosphor-logging/elog.hpp>
+#include <phosphor-logging/elog-errors.hpp>
+#include <xyz/openbmc_project/Common/error.hpp>
 
 
+using namespace phosphor::logging;
+using InternalFailure = sdbusplus::xyz::openbmc_project::Common::
+                            Error::InternalFailure;
+
 namespace phosphor
 {
 namespace fan
@@ -43,8 +51,10 @@
             fd = ::open(pathname.c_str(), flags);
             if (-1 == fd)
             {
-                throw std::runtime_error(
-                    "Failed to open file device: " + pathname);
+                log<level::ERR>(
+                     "Failed to open file device: ",
+                     entry("PATHNAME=%s", pathname.c_str()));
+                elog<InternalFailure>();
             }
         }