Extract error handlers to seperate file