summaryrefslogtreecommitdiffstats
path: root/utils.hpp
diff options
context:
space:
mode:
authorLei YU <mine260309@gmail.com>2017-07-12 13:12:12 +0800
committerLei YU <mine260309@gmail.com>2017-10-16 20:40:04 +0800
commit86d80419c72699862ee498ec9e37fd02ccf3ebb1 (patch)
tree3c2ffa9107ba13d59e159ad14daf714a5fc77b4d /utils.hpp
parent23d06af53140366be1aba634014929182897174e (diff)
downloadphosphor-time-manager-86d80419c72699862ee498ec9e37fd02ccf3ebb1.tar.gz
phosphor-time-manager-86d80419c72699862ee498ec9e37fd02ccf3ebb1.zip
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>
Diffstat (limited to 'utils.hpp')
-rw-r--r--utils.hpp16
1 files changed, 10 insertions, 6 deletions
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 @@ namespace utils
{
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 @@ T getProperty(sdbusplus::bus::bus& bus,
}
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>();
}
OpenPOWER on IntegriCloud