Implement an application-wide error handler

Implemented and events module which can handle events emitted from anywhere in the application. Can be used to handle database errors or exceptions across the application.