如下两种 都捕获不到,为什么?
function main1() {
try {
new Promise(() => {
throw new Error('promise1 error')
})
} catch(e) {
console.log(e.message);
}
}
function main2() {
try {
Promise.reject('promise2 error');
} catch(e) {
console.log(e.message);
}
}
promise 内部 已经加了 try catch 处理了异常,所以不能冒泡到外面。