sdbus++: events: use sd_bus_error_add_map to register

Register errors with `sd_bus_error_add_map` so that `errno`
translation is handled appropriately.

Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
Change-Id: I61e0cbed239a44842c6ea598904ac4411e195588
diff --git a/tools/sdbusplus/templates/events.cpp.mako b/tools/sdbusplus/templates/events.cpp.mako
index 737d5bd..0600952 100644
--- a/tools/sdbusplus/templates/events.cpp.mako
+++ b/tools/sdbusplus/templates/events.cpp.mako
@@ -10,7 +10,20 @@
 ${events.render(loader, "event.cpp.mako", events=events, event=e)}\
 % endfor
 
+/* Load error map into sd_bus for errno translation. */
+static sd_bus_error_map errors[] = {
+% for e in events.errors:
+    SD_BUS_ERROR_MAP(${e.CamelCase}::errName, ${e.CamelCase}::errErrno),
+% endfor
+    SD_BUS_ERROR_MAP_END
+};
+[[gnu::constructor]] static void loadErrors()
+{
+    sd_bus_error_add_map(errors);
+}
+
 } // namespace sdbusplus::error::${events.cppNamespacedClass()}
+
 %endif
 %if events.errors: