Added generic error handling into the express middleware