koa如何处理自定义错误 并且可以让前端在promise的catch中捕获?

koa如何处理自定义错误 并且可以让前端在promise的catch中捕获?

最佳答案

让 http 请求的 响应状态 status 是 5开头 或者 4 开头;前端的ajax 都会进入到 error中去