美文网首页
promise then failure catch

promise then failure catch

作者: peerben | 来源:发表于2018-09-02 12:31 被阅读6次
(new Promise(function(resolve, reject) {
    resolve('aa');
})).then(val => { console.log(val); throw new Error('aaa');}).catch((err)=> console.log('err' + err));

aa
errError: aaa

(new Promise(function(resolve, reject) {
    resolve('aa');
})).then(val => { 
    console.log(val); 
    throw new Error('aaa');
}).then((a)=>a, (val) => { console.log('reject'); }).catch((err)=> console.log('err' + err));

aa
reject

(new Promise(function(resolve, reject) {
    resolve('aa');
})).then(val => { 
    console.log(val); 
    throw new Error('aaa');
}).then((a)=>a).catch((err)=> console.log('err' + err));

aa
errError: aaa

相关文章

网友评论

      本文标题:promise then failure catch

      本文链接:https://www.haomeiwen.com/subject/kunpwftx.html