在组件里面调用dispatch,返回的promise未能catch异常

发布于 2022-09-12 02:52:19 字数 1151 浏览 11 评论 0

背景

在action中call一个api,api报错,这个错误在组件的dispatch中捕获不到。

浏览器报错

uncaught at _callee3 at _callee3 
 at _callee6 
 at takeEvery(tagEditModel/addCategory, _callee) 
 at _callee 
 at _callee 
 Error: Error: 错误测试
    at addCategory$ (http://localhost:8000/umi.js:93924:21)
    at tryCatch (http://localhost:8000/umi.js:77209:40)
    at Generator.invoke [as _invoke] (http://localhost:8000/umi.js:77435:22)
    at Generator.prototype.(anonymous function) [as next] (http://localhost:8000/umi.js:77261:21)
    at next (http://localhost:8000/umi.js:75226:27)
    at proc (http://localhost:8000/umi.js:75185:3)
    at resolveIterator (http://localhost:8000/umi.js:75371:5)
    at runEffect (http://localhost:8000/umi.js:75347:178)
    at next (http://localhost:8000/umi.js:75230:9)
    at currCb (http://localhost:8000/umi.js:75303:7)
    at http://localhost:8000/umi.js:75414:16
    at exec (http://localhost:8000/umi.js:76081:5)
    at flush (http://localhost:8000/umi.js:76122:5)
    at asap (http://localhost:8000/umi.js:76095:5)
    at Array.<anonymous> (http://localhost:8000/umi.js:74456:27)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

森罗 2022-09-19 02:52:19

dva config里要注册onError方法,否则错误不上抛

WechatIMG1.png

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文