Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
501 views
in Technique[技术] by (71.8m points)

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

背景

在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)

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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

WechatIMG1.png


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...