Add Shutdown error

This error is for when the system had to be shut down
due to a power fault to avoid leaving the system in a
possibly dangerous state.

The elog-errors.hpp header file was generated by running
phosphor-logging/tools/elog-gen.py against the yaml.

Change-Id: I6fd7b9562cb3e0c8b32bcd1a18934d250a3ac896
Signed-off-by: Matt Spinler <spinler@us.ibm.com>
diff --git a/Makefile.am b/Makefile.am
index 20ab498..37f0039 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -4,14 +4,32 @@
 libpower_la_LDFLAGS = -static
 libpower_la_LIBADD = \
 	$(PHOSPHOR_LOGGING_LIBS) \
-	$(SDBUSPLUS_LIBS)
+	$(SDBUSPLUS_LIBS) \
+	$(PHOSPHOR_DBUS_INTERFACES_LIBS)
 libpower_la_CXXFLAGS = \
 	$(PHOSPHOR_LOGGING_CFLAGS) \
-	$(SDBUSPLUS_CFLAGS)
+	$(SDBUSPLUS_CFLAGS) \
+	$(PHOSPHOR_DBUS_INTERFACES_CFLAGS)
 
 libpower_la_SOURCES = \
 	pmbus.cpp \
 	timer.cpp \
-	utility.cpp
+	utility.cpp \
+	xyz/openbmc_project/Power/Fault/error.cpp
+
+nobase_nodist_include_HEADERS = \
+	xyz/openbmc_project/Power/Fault/error.hpp
+
+BUILT_SOURCES = \
+	xyz/openbmc_project/Power/Fault/error.cpp \
+	xyz/openbmc_project/Power/Fault/error.hpp
+
+xyz/openbmc_project/Power/Fault/error.hpp: ${srcdir}/xyz/openbmc_project/Power/Fault.errors.yaml
+	@mkdir -p `dirname $@`
+	$(SDBUSPLUSPLUS) -r $(srcdir) error exception-header xyz.openbmc_project.Power.Fault > $@
+
+xyz/openbmc_project/Power/Fault/error.cpp: ${srcdir}/xyz/openbmc_project/Power/Fault.errors.yaml
+	@mkdir -p `dirname $@`
+	$(SDBUSPLUSPLUS) -r $(srcdir) error exception-cpp xyz.openbmc_project.Power.Fault > $@
 
 SUBDIRS = .
diff --git a/configure.ac b/configure.ac
index 7a2f09b..0de3990 100644
--- a/configure.ac
+++ b/configure.ac
@@ -23,6 +23,10 @@
     AC_MSG_ERROR(["Requires phosphor-logging package."]))
 PKG_CHECK_MODULES([PHOSPHOR_DBUS_INTERFACES], [phosphor-dbus-interfaces],,\
     AC_MSG_ERROR(["Requires phosphor-dbus-interfaces package."]))
+# Check for sdbus++
+AC_PATH_PROG([SDBUSPLUSPLUS], [sdbus++])
+AS_IF([test "x$SDBUSPLUSPLUS" == "x"],
+    AC_MSG_ERROR(["Requires sdbus++"]))
 
 # Checks for library functions.
 LT_INIT # Required for systemd linking
diff --git a/elog-errors.hpp b/elog-errors.hpp
new file mode 100644
index 0000000..1fe8470
--- /dev/null
+++ b/elog-errors.hpp
@@ -0,0 +1,80 @@
+// This file was autogenerated.  Do not edit!
+// See elog-gen.py for more details
+#pragma once
+
+#include <string>
+#include <tuple>
+#include <type_traits>
+#include <sdbusplus/exception.hpp>
+#include <phosphor-logging/log.hpp>
+#include <phosphor-logging/elog.hpp>
+
+namespace sdbusplus
+{
+namespace xyz
+{
+namespace openbmc_project
+{
+namespace Power
+{
+namespace Fault
+{
+namespace Error
+{
+    struct Shutdown;
+} // namespace Error
+} // namespace Fault
+} // namespace Power
+} // namespace openbmc_project
+} // namespace xyz
+} // namespace sdbusplus
+
+
+namespace phosphor
+{
+
+namespace logging
+{
+
+namespace xyz
+{
+namespace openbmc_project
+{
+namespace Power
+{
+namespace Fault
+{
+namespace _Shutdown
+{
+
+
+}  // namespace _Shutdown
+
+struct Shutdown
+{
+    static constexpr auto L = level::ERR;
+    using metadata_types = std::tuple<>;
+
+};
+
+} // namespace Fault
+} // namespace Power
+} // namespace openbmc_project
+} // namespace xyz
+
+
+namespace details
+{
+
+template <>
+struct map_exception_type<sdbusplus::xyz::openbmc_project::Power::Fault::Error::Shutdown>
+{
+    using type = xyz::openbmc_project::Power::Fault::Shutdown;
+};
+
+}
+
+
+} // namespace logging
+
+} // namespace phosphor
diff --git a/xyz/openbmc_project/Power/Fault.errors.yaml b/xyz/openbmc_project/Power/Fault.errors.yaml
new file mode 100644
index 0000000..e646d02
--- /dev/null
+++ b/xyz/openbmc_project/Power/Fault.errors.yaml
@@ -0,0 +1,2 @@
+- name: Shutdown
+  description: A power off was issued because a power fault was detected
diff --git a/xyz/openbmc_project/Power/Fault.metadata.yaml b/xyz/openbmc_project/Power/Fault.metadata.yaml
new file mode 100644
index 0000000..72bb884
--- /dev/null
+++ b/xyz/openbmc_project/Power/Fault.metadata.yaml
@@ -0,0 +1,2 @@
+- name: Shutdown
+  level: ERR