summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDhruvaraj Subhashchandran <dhruvaraj@in.ibm.com>2017-05-15 05:06:36 -0500
committerDhruvaraj Subhashchandran <dhruvaraj@in.ibm.com>2017-05-17 04:02:38 -0500
commit7ce535cb8cb9e98e64eb307d060e9a6ebf428116 (patch)
tree2017649a67ad7ebc7e2326d052926e825bcda42d
parent18b0786a93964c2f30ada2e5405b103d4d3b82e5 (diff)
downloadopenpower-proc-control-7ce535cb8cb9e98e64eb307d060e9a6ebf428116.tar.gz
openpower-proc-control-7ce535cb8cb9e98e64eb307d060e9a6ebf428116.zip
Replacing runtime exceptions with elog
Resolves openbmc/openbmc#1323 Change-Id: Ia93d1f0036341c26fdc6c5e3133d4a05346090be Signed-off-by: Dhruvaraj Subhashchandran <dhruvaraj@in.ibm.com>
-rw-r--r--Makefile.am6
-rw-r--r--configure.ac2
-rw-r--r--elog-errors.hpp231
-rw-r--r--proc_control.cpp6
-rw-r--r--procedures/p9/cfam_overrides.cpp11
5 files changed, 251 insertions, 5 deletions
diff --git a/Makefile.am b/Makefile.am
index 942b5d7..474e998 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -13,8 +13,10 @@ openpower_proc_control_SOURCES = \
CLEANFILES = openpower_procedures.cpp
-openpower_proc_control_LDFLAGS = $(PHOSPHOR_LOGGING_LIBS) -lstdc++fs
-openpower_proc_control_CXXFLAGS = $(PHOSPHOR_LOGGING_CFLAGS)
+openpower_proc_control_LDFLAGS = $(PHOSPHOR_LOGGING_LIBS) -lstdc++fs \
+ $(PHOSPHOR_DBUS_INTERFACES_LIBS)
+openpower_proc_control_CXXFLAGS = $(PHOSPHOR_LOGGING_CFLAGS) \
+ $(PHOSPHOR_DBUS_INTERFACES_CFLAGS)
SUBDIRS = test
diff --git a/configure.ac b/configure.ac
index 0234491..cc2d823 100644
--- a/configure.ac
+++ b/configure.ac
@@ -46,6 +46,6 @@ AC_CONFIG_FILES([Makefile.generated],
[myChips="$CHIPS"])
PKG_CHECK_MODULES([PHOSPHOR_LOGGING], [phosphor-logging],, [AC_MSG_ERROR([Could not find phosphor-logging...openbmc/phosphor-logging package required])])
-
+PKG_CHECK_MODULES([PHOSPHOR_DBUS_INTERFACES], [phosphor-dbus-interfaces], [], [AC_MSG_ERROR(["phosphor-dbus-interfaces required and not found."])])
AC_CONFIG_FILES([Makefile test/Makefile])
AC_OUTPUT
diff --git a/elog-errors.hpp b/elog-errors.hpp
index b833f34..9443399 100644
--- a/elog-errors.hpp
+++ b/elog-errors.hpp
@@ -17,6 +17,23 @@ namespace openbmc_project
{
namespace Common
{
+namespace Error
+{
+ struct Timeout;
+} // namespace Error
+} // namespace Common
+} // namespace openbmc_project
+} // namespace xyz
+} // namespace sdbusplus
+
+namespace sdbusplus
+{
+namespace xyz
+{
+namespace openbmc_project
+{
+namespace Common
+{
namespace Callout
{
namespace Error
@@ -117,6 +134,23 @@ namespace openbmc_project
{
namespace Common
{
+namespace Error
+{
+ struct InternalFailure;
+} // namespace Error
+} // namespace Common
+} // namespace openbmc_project
+} // namespace xyz
+} // namespace sdbusplus
+
+namespace sdbusplus
+{
+namespace xyz
+{
+namespace openbmc_project
+{
+namespace Common
+{
namespace Callout
{
namespace Error
@@ -177,6 +211,23 @@ namespace openbmc_project
{
namespace Common
{
+namespace Error
+{
+ struct InvalidArgument;
+} // namespace Error
+} // namespace Common
+} // namespace openbmc_project
+} // namespace xyz
+} // namespace sdbusplus
+
+namespace sdbusplus
+{
+namespace xyz
+{
+namespace openbmc_project
+{
+namespace Common
+{
namespace Callout
{
namespace Error
@@ -807,6 +858,186 @@ struct map_exception_type<sdbusplus::org::open_power::Proc::CFAM::Error::SeekFai
}
+namespace xyz
+{
+namespace openbmc_project
+{
+namespace Common
+{
+namespace _Timeout
+{
+
+struct TIMEOUT_IN_MSEC
+{
+ static constexpr auto str = "TIMEOUT_IN_MSEC=%llu";
+ static constexpr auto str_short = "TIMEOUT_IN_MSEC";
+ using type = std::tuple<std::decay_t<decltype(str)>,uint64_t>;
+ explicit constexpr TIMEOUT_IN_MSEC(uint64_t a) : _entry(entry(str, a)) {};
+ type _entry;
+};
+
+} // namespace _Timeout
+
+struct Timeout : public sdbusplus::exception_t
+{
+ static constexpr auto errName = "xyz.openbmc_project.Common.Timeout";
+ static constexpr auto errDesc = "Operation timed out.";
+ static constexpr auto L = level::INFO;
+ using TIMEOUT_IN_MSEC = _Timeout::TIMEOUT_IN_MSEC;
+ using metadata_types = std::tuple<TIMEOUT_IN_MSEC>;
+
+ const char* name() const noexcept
+ {
+ return errName;
+ }
+
+ const char* description() const noexcept
+ {
+ return errDesc;
+ }
+
+ const char* what() const noexcept
+ {
+ return errName;
+ }
+};
+
+} // namespace Common
+} // namespace openbmc_project
+} // namespace xyz
+
+
+namespace details
+{
+
+template <>
+struct map_exception_type<sdbusplus::xyz::openbmc_project::Common::Error::Timeout>
+{
+ using type = xyz::openbmc_project::Common::Timeout;
+};
+
+}
+
+namespace xyz
+{
+namespace openbmc_project
+{
+namespace Common
+{
+namespace _InvalidArgument
+{
+
+struct ARGUMENT_NAME
+{
+ static constexpr auto str = "ARGUMENT_NAME=%s";
+ static constexpr auto str_short = "ARGUMENT_NAME";
+ using type = std::tuple<std::decay_t<decltype(str)>,const char*>;
+ explicit constexpr ARGUMENT_NAME(const char* a) : _entry(entry(str, a)) {};
+ type _entry;
+};
+struct ARGUMENT_VALUE
+{
+ static constexpr auto str = "ARGUMENT_VALUE=%s";
+ static constexpr auto str_short = "ARGUMENT_VALUE";
+ using type = std::tuple<std::decay_t<decltype(str)>,const char*>;
+ explicit constexpr ARGUMENT_VALUE(const char* a) : _entry(entry(str, a)) {};
+ type _entry;
+};
+
+} // namespace _InvalidArgument
+
+struct InvalidArgument : public sdbusplus::exception_t
+{
+ static constexpr auto errName = "xyz.openbmc_project.Common.InvalidArgument";
+ static constexpr auto errDesc = "Invalid argument was given.";
+ static constexpr auto L = level::INFO;
+ using ARGUMENT_NAME = _InvalidArgument::ARGUMENT_NAME;
+ using ARGUMENT_VALUE = _InvalidArgument::ARGUMENT_VALUE;
+ using metadata_types = std::tuple<ARGUMENT_NAME, ARGUMENT_VALUE>;
+
+ const char* name() const noexcept
+ {
+ return errName;
+ }
+
+ const char* description() const noexcept
+ {
+ return errDesc;
+ }
+
+ const char* what() const noexcept
+ {
+ return errName;
+ }
+};
+
+} // namespace Common
+} // namespace openbmc_project
+} // namespace xyz
+
+
+namespace details
+{
+
+template <>
+struct map_exception_type<sdbusplus::xyz::openbmc_project::Common::Error::InvalidArgument>
+{
+ using type = xyz::openbmc_project::Common::InvalidArgument;
+};
+
+}
+
+namespace xyz
+{
+namespace openbmc_project
+{
+namespace Common
+{
+namespace _InternalFailure
+{
+
+
+} // namespace _InternalFailure
+
+struct InternalFailure : public sdbusplus::exception_t
+{
+ static constexpr auto errName = "xyz.openbmc_project.Common.InternalFailure";
+ static constexpr auto errDesc = "The operation failed internally.";
+ static constexpr auto L = level::ERR;
+ using metadata_types = std::tuple<>;
+
+ const char* name() const noexcept
+ {
+ return errName;
+ }
+
+ const char* description() const noexcept
+ {
+ return errDesc;
+ }
+
+ const char* what() const noexcept
+ {
+ return errName;
+ }
+};
+
+} // namespace Common
+} // namespace openbmc_project
+} // namespace xyz
+
+
+namespace details
+{
+
+template <>
+struct map_exception_type<sdbusplus::xyz::openbmc_project::Common::Error::InternalFailure>
+{
+ using type = xyz::openbmc_project::Common::InternalFailure;
+};
+
+}
+
} // namespace logging
diff --git a/proc_control.cpp b/proc_control.cpp
index a86b354..aceb6d6 100644
--- a/proc_control.cpp
+++ b/proc_control.cpp
@@ -20,6 +20,7 @@
#include <phosphor-logging/elog.hpp>
#include "registration.hpp"
#include "elog-errors.hpp"
+#include <xyz/openbmc_project/Common/error.hpp>
using namespace openpower::util;
@@ -79,6 +80,11 @@ int main(int argc, char** argv)
commit<org::open_power::Proc::CFAM::ReadFailure>();
return -1;
}
+ catch (sdbusplus::xyz::openbmc_project::Common::Error::InvalidArgument& e)
+ {
+ commit<sdbusplus::xyz::openbmc_project::Common::Error::InvalidArgument>();
+ return -1;
+ }
return 0;
}
diff --git a/procedures/p9/cfam_overrides.cpp b/procedures/p9/cfam_overrides.cpp
index 90891b9..f3436ee 100644
--- a/procedures/p9/cfam_overrides.cpp
+++ b/procedures/p9/cfam_overrides.cpp
@@ -5,6 +5,8 @@
#include "p9_cfam.hpp"
#include "registration.hpp"
#include "targeting.hpp"
+#include "elog-errors.hpp"
+#include <xyz/openbmc_project/Common/error.hpp>
/* File /var/lib/obmc/cfam_overrides requires whitespace-separated parameters
Pos Address Data Mask with one register write per line. For example:
@@ -51,8 +53,13 @@ void CFAMOverride() {
}
else
{
- throw std::runtime_error("Cannot write to register - "
- "not enough parameters given.");
+ namespace error =
+ sdbusplus::xyz::openbmc_project::Common::Error;
+ namespace metadata =
+ phosphor::logging::xyz::openbmc_project::Common;
+ phosphor::logging::elog<error::InvalidArgument>(
+ metadata::InvalidArgument::ARGUMENT_NAME("line"),
+ metadata::InvalidArgument::ARGUMENT_VALUE(line.c_str()));
}
}
}
OpenPOWER on IntegriCloud