在ES6 Promise
中,catch
和then(_,onRejected)
之间有什么区别?我只知道onRejected
不能处理内部Promise
的拒绝状态。
Promise.resolve().then(() => {
return new Promise((resolve,reject) => {
throw new Error('Error occurs');
});
},er => console.log(er)); //Chrome throws `Uncaught (in promise)`
Promise.resolve().then(() => {
return new Promise((resolve,reject) => {
throw new Error('Error occurs');
});
}).catch(er => console.log(er)); //Error occurs