factor out error handlers into separate file
WIP