Commit errorlog and exit the application on error scenarios

This application interacts with OCC driver and hence its good to
terminate when there is an error during IO since it would mostly
mean a faulty hardware.

Fixes openbmc/openbmc#1428

Change-Id: I48bc7b2cf19922a7a53dbab78cdd4f2338a7431b
Signed-off-by: Vishwanatha Subbanna <vishwa@linux.vnet.ibm.com>
diff --git a/Makefile.am b/Makefile.am
index 2bdbd26..50d23da 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -7,13 +7,28 @@
 openpower_occ_control_SOURCES = \
 	occ_finder.cpp \
 	occ_pass_through.cpp \
-	app.cpp
+	app.cpp \
+	org/open_power/OCC/PassThrough/error.cpp
+
+BUILT_SOURCES =  org/open_power/OCC/PassThrough/error.hpp \
+                 org/open_power/OCC/PassThrough/error.cpp
+
+CLEANFILES = ${BUILT_SOURCES}
 
 openpower_occ_control_LDFLAGS = \
 	$(SDBUSPLUS_LIBS) \
 	$(PHOSPHOR_LOGGING_LIBS) \
 	$(OPENPOWER_DBUS_INTERFACES_LIBS)
+
 openpower_occ_control_CXXFLAGS =
 	$(SDBUSPLUS_CFLAGS) \
 	$(PHOSPHOR_LOGGING_CFLAGS) \
 	$(OPENPOWER_DBUS_INTERFACES_CFLAGS)
+
+org/open_power/OCC/PassThrough/error.hpp: ${top_srcdir}/org/open_power/OCC/PassThrough.errors.yaml
+	@mkdir -p `dirname $@`
+	$(SDBUSPLUSPLUS) -r $(top_srcdir) error exception-header org.open_power.OCC.PassThrough > $@
+
+org/open_power/OCC/PassThrough/error.cpp: ${top_srcdir}/org/open_power/OCC/PassThrough.errors.yaml
+	@mkdir -p `dirname $@`
+	$(SDBUSPLUSPLUS) -r $(top_srcdir) error exception-cpp org.open_power.OCC.PassThrough > $@