Add repo specific errors

1. Add Internal.errors.yaml to define repo specific errors
2. Update configure.ac and Makefile.am to generate code from error yamls
3. Add elog-gen.hpp generated by elog-gen.py

Change-Id: I6858f2c9f3c2100ce106d1effe7ad3f340117fec
Signed-off-by: Lei YU <mine260309@gmail.com>
diff --git a/.gitignore b/.gitignore
index 5cde092..256b418 100644
--- a/.gitignore
+++ b/.gitignore
@@ -48,6 +48,7 @@
 phosphor-timemanager
 *-libtool
 .libs
+/xyz/openbmc_project/Time/Internal/*
 
 # UT related items
 .dirstamp
diff --git a/Makefile.am b/Makefile.am
index 57734d1..bf7a559 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -4,12 +4,20 @@
 
 noinst_LTLIBRARIES = libtimemanager.la
 
+generated_source = xyz/openbmc_project/Time/Internal/error.cpp
+
+BUILT_SOURCES = ${generated_source} \
+				xyz/openbmc_project/Time/Internal/error.hpp
+
+CLEANFILES = ${BUILT_SOURCES}
+
 libtimemanager_la_SOURCES = \
 	epoch_base.cpp \
 	bmc_epoch.cpp \
 	host_epoch.cpp \
 	manager.cpp \
-	utils.cpp
+	utils.cpp \
+	${generated_source}
 
 phosphor_timemanager_SOURCES = \
 	main.cpp
@@ -29,4 +37,12 @@
 
 phosphor_timemanager_LDFLAGS = $(generic_ld_flags)
 
+xyz/openbmc_project/Time/Internal/error.hpp: ${top_srcdir}/xyz/openbmc_project/Time/Internal.errors.yaml
+	@mkdir -p `dirname $@`
+	$(SDBUSPLUSPLUS) -r $(top_srcdir) error exception-header xyz.openbmc_project.Time.Internal > $@
+
+xyz/openbmc_project/Time/Internal/error.cpp: ${top_srcdir}/xyz/openbmc_project/Time/Internal.errors.yaml
+	@mkdir -p `dirname $@`
+	$(SDBUSPLUSPLUS) -r $(top_srcdir) error exception-cpp xyz.openbmc_project.Time.Internal> $@
+
 SUBDIRS = . test
diff --git a/configure.ac b/configure.ac
index 7a2ee4e..aa54962 100644
--- a/configure.ac
+++ b/configure.ac
@@ -47,6 +47,10 @@
     AC_SUBST([OESDK_TESTCASE_FLAGS], [$testcase_flags])
 )
 
+# Check for sdbus++ tool
+AC_PATH_PROG([SDBUSPLUSPLUS], [sdbus++])
+AS_IF([test "x$SDBUSPLUSPLUS" == "x"], AC_MSG_ERROR([Cannot find sdbus++]))
+
 # Checks for typedefs, structures, and compiler characteristics.
 AX_CXX_COMPILE_STDCXX_14([noext])
 AX_APPEND_COMPILE_FLAGS([-fpic -Wall -Werror], [CXXFLAGS])
diff --git a/elog-errors.hpp b/elog-errors.hpp
new file mode 100644
index 0000000..aa8d581
--- /dev/null
+++ b/elog-errors.hpp
@@ -0,0 +1,116 @@
+// 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 Time
+{
+namespace Internal
+{
+namespace Error
+{
+    struct MethodError;
+} // namespace Error
+} // namespace Internal
+} // namespace Time
+} // namespace openbmc_project
+} // namespace xyz
+} // namespace sdbusplus
+
+
+namespace phosphor
+{
+
+namespace logging
+{
+
+namespace xyz
+{
+namespace openbmc_project
+{
+namespace Time
+{
+namespace Internal
+{
+namespace _MethodError
+{
+
+struct METHOD_NAME
+{
+    static constexpr auto str = "METHOD_NAME=%s";
+    static constexpr auto str_short = "METHOD_NAME";
+    using type = std::tuple<std::decay_t<decltype(str)>,const char*>;
+    explicit constexpr METHOD_NAME(const char* a) : _entry(entry(str, a)) {};
+    type _entry;
+};
+struct PATH
+{
+    static constexpr auto str = "PATH=%s";
+    static constexpr auto str_short = "PATH";
+    using type = std::tuple<std::decay_t<decltype(str)>,const char*>;
+    explicit constexpr PATH(const char* a) : _entry(entry(str, a)) {};
+    type _entry;
+};
+struct INTERFACE
+{
+    static constexpr auto str = "INTERFACE=%s";
+    static constexpr auto str_short = "INTERFACE";
+    using type = std::tuple<std::decay_t<decltype(str)>,const char*>;
+    explicit constexpr INTERFACE(const char* a) : _entry(entry(str, a)) {};
+    type _entry;
+};
+struct MISC
+{
+    static constexpr auto str = "MISC=%s";
+    static constexpr auto str_short = "MISC";
+    using type = std::tuple<std::decay_t<decltype(str)>,const char*>;
+    explicit constexpr MISC(const char* a) : _entry(entry(str, a)) {};
+    type _entry;
+};
+
+}  // namespace _MethodError
+
+struct MethodError
+{
+    static constexpr auto L = level::ERR;
+    using METHOD_NAME = _MethodError::METHOD_NAME;
+    using PATH = _MethodError::PATH;
+    using INTERFACE = _MethodError::INTERFACE;
+    using MISC = _MethodError::MISC;
+    using metadata_types = std::tuple<METHOD_NAME, PATH, INTERFACE, MISC>;
+
+};
+
+} // namespace Internal
+} // namespace Time
+} // namespace openbmc_project
+} // namespace xyz
+
+
+namespace details
+{
+
+template <>
+struct map_exception_type<sdbusplus::xyz::openbmc_project::Time::Internal::Error::MethodError>
+{
+    using type = xyz::openbmc_project::Time::Internal::MethodError;
+};
+
+}
+
+
+} // namespace logging
+
+} // namespace phosphor
diff --git a/xyz/openbmc_project/Time/Internal.errors.yaml b/xyz/openbmc_project/Time/Internal.errors.yaml
new file mode 100644
index 0000000..a2502ab
--- /dev/null
+++ b/xyz/openbmc_project/Time/Internal.errors.yaml
@@ -0,0 +1,3 @@
+#xyz.openbmc_project.Time.Internal.MethodError
+- name: MethodError
+  description: Failed to invoke Dbus method
diff --git a/xyz/openbmc_project/Time/Internal.metadata.yaml b/xyz/openbmc_project/Time/Internal.metadata.yaml
new file mode 100644
index 0000000..0f16c11
--- /dev/null
+++ b/xyz/openbmc_project/Time/Internal.metadata.yaml
@@ -0,0 +1,10 @@
+- name: MethodError
+  meta:
+    - str: "METHOD_NAME=%s"
+      type: string
+    - str: "PATH=%s"
+      type: string
+    - str: "INTERFACE=%s"
+      type: string
+    - str: "MISC=%s"
+      type: string