Move error handlers to errors file and add a function to register all error handlers.