diff options
author | Lei YU <mine260309@gmail.com> | 2017-07-12 13:12:12 +0800 |
---|---|---|
committer | Lei YU <mine260309@gmail.com> | 2017-10-16 20:40:04 +0800 |
commit | 86d80419c72699862ee498ec9e37fd02ccf3ebb1 (patch) | |
tree | 3c2ffa9107ba13d59e159ad14daf714a5fc77b4d /utils.hpp | |
parent | 23d06af53140366be1aba634014929182897174e (diff) | |
download | phosphor-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.hpp | 16 |
1 files changed, 10 insertions, 6 deletions
@@ -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>(); } |