Use elog to throw exceptions

Use elog to throw exceptions and update unit tests

Change-Id: I338ded4403b3b559a84da311eda5ee15e712569a
Signed-off-by: Lei YU <mine260309@gmail.com>
diff --git a/utils.hpp b/utils.hpp
index ea2e3e4..87bc2bf 100644
--- a/utils.hpp
+++ b/utils.hpp
@@ -1,7 +1,10 @@
 #pragma once
 
+#include "elog-errors.hpp"
 #include "types.hpp"
+#include "xyz/openbmc_project/Time/Internal/error.hpp"
 
+#include <phosphor-logging/elog.hpp>
 #include <phosphor-logging/log.hpp>
 #include <sdbusplus/bus.hpp>
 
@@ -15,6 +18,8 @@
 {
 
 using namespace phosphor::logging;
+using MethodErr =
+    sdbusplus::xyz::openbmc_project::Time::Internal::Error::MethodError;
 
 /** @brief Read data with type T from file
  *
@@ -79,12 +84,11 @@
     }
     else
     {
-        // TODO: use elog to throw exception
-        log<level::ERR>("Failed to get property",
-                        entry("SERVICE=%s", service),
-                        entry("PATH=%s", path),
-                        entry("INTERFACE=%s", interface),
-                        entry("PROPERTY=%s", propertyName));
+        using namespace xyz::openbmc_project::Time::Internal;
+        elog<MethodErr>(MethodError::METHOD_NAME("Get"),
+                          MethodError::PATH(path),
+                          MethodError::INTERFACE(interface),
+                          MethodError::MISC(propertyName));
     }
     return value.template get<T>();
 }