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/monitor/Makefile.am b/monitor/Makefile.am
index f54248e..7b5fdae 100644
--- a/monitor/Makefile.am
+++ b/monitor/Makefile.am
@@ -17,11 +17,13 @@
 phosphor_fan_monitor_LDADD = \
 	$(top_builddir)/libfan.la \
 	$(SDBUSPLUS_LIBS) \
-	$(PHOSPHOR_LOGGING_LIBS)
+	$(PHOSPHOR_LOGGING_LIBS) \
+	${PHOSPHOR_DBUS_INTERFACES_LIBS}
 
 phosphor_fan_monitor_CXXFLAGS = \
 	$(SDBUSPLUS_CFLAGS) \
-	$(PHOSPHOR_LOGGING_CFLAGS)
+	$(PHOSPHOR_LOGGING_CFLAGS) \
+	${PHOSPHOR_DBUS_INTERFACES_CFLAGS}
 
 fan_monitor_defs.cpp: ${srcdir}/gen-fan-monitor-defs.py
 	$(AM_V_GEN)$(GEN_FAN_MONITOR_DEFS)
diff --git a/monitor/fan.cpp b/monitor/fan.cpp
index 17f5812..195317c 100644
--- a/monitor/fan.cpp
+++ b/monitor/fan.cpp
@@ -199,15 +199,7 @@
     ObjectMap objectMap = getObjectMap(functional);
     std::string service;
 
-    try
-    {
-        service = phosphor::fan::util::getInvService(_bus);
-    }
-    catch (const std::runtime_error& err)
-    {
-        log<level::ERR>(err.what());
-        return;
-    }
+    service = phosphor::fan::util::getInvService(_bus);
 
     auto msg = _bus.new_method_call(service.c_str(),
                                    INVENTORY_PATH,
diff --git a/monitor/tach_sensor.cpp b/monitor/tach_sensor.cpp
index 80eb974..2ece054 100644
--- a/monitor/tach_sensor.cpp
+++ b/monitor/tach_sensor.cpp
@@ -14,6 +14,9 @@
  * limitations under the License.
  */
 #include <phosphor-logging/log.hpp>
+#include <phosphor-logging/elog.hpp>
+#include <phosphor-logging/elog-errors.hpp>
+#include <xyz/openbmc_project/Common/error.hpp>
 #include "fan.hpp"
 #include "tach_sensor.hpp"
 #include "../utility.hpp"
@@ -25,6 +28,10 @@
 namespace monitor
 {
 
+using namespace phosphor::logging;
+using InternalFailure = sdbusplus::xyz::openbmc_project::Common::
+                            Error::InternalFailure;
+
 constexpr auto PROPERTY_INTF = "org.freedesktop.DBus.Properties";
 constexpr auto FAN_SENSOR_PATH = "/xyz/openbmc_project/sensors/fan_tach/";
 constexpr auto FAN_SENSOR_CONTROL_INTF = "xyz.openbmc_project.Control.FanSpeed";
@@ -65,9 +72,9 @@
         auto reply = bus.call(method);
         if (reply.is_method_error())
         {
-            throw std::runtime_error(
-                "Error in property get call for path " +
-                path);
+            log<level::ERR>("Error in property get call",
+                entry("PATH=%s", path.c_str()));
+            elog<InternalFailure>();
         }
 
         reply.read(property);