refactor error handlers with new flow-control