sdbus++: generate error header

Change-Id: I6e1beb1da2b5c3c3ea612b9aa688ea037d6173e6
diff --git a/tools/sdbusplus/error.py b/tools/sdbusplus/error.py
index ff3926c..c67eee0 100644
--- a/tools/sdbusplus/error.py
+++ b/tools/sdbusplus/error.py
@@ -24,4 +24,4 @@
         super(Error, self).__init__(**kwargs)
 
     def exception_header(self, loader):
-        return ""
+        return self.render(loader, "error.mako.hpp", error=self)
diff --git a/tools/sdbusplus/templates/error.mako.hpp b/tools/sdbusplus/templates/error.mako.hpp
new file mode 100644
index 0000000..9f4f7f8
--- /dev/null
+++ b/tools/sdbusplus/templates/error.mako.hpp
@@ -0,0 +1,29 @@
+#pragma once
+
+#include <sdbusplus/exception.hpp>
+<% namespaces = error.name.split('.') %>
+namespace sdbusplus
+{
+    % for s in namespaces:
+namespace ${s}
+{
+    % endfor
+namespace common
+{
+
+    % for e in error.errors:
+struct ${e.name} : public sdbusplus::exception_t
+{
+    static constexpr auto name = "${error.name}.${e.name}";
+    static constexpr auto description =
+            "${e.description.strip()}";
+
+    const char* what() const noexcept override;
+};
+
+    % endfor
+} // namespace common
+    % for s in reversed(namespaces):
+} // namespace ${s}
+    % endfor
+} // namespace sdbusplus