rewrite async error handler