Error will not catch in try catc
2019-05-25 本文已影响0人
超薄智能
Sometime cannot use await function in a callback, use promise chain will be ok
var process1 = ()=>{
try{
promise;
}catch(error){
console.log(error);
}
}
var process2 = ()=>{
promise.then().catch(error=>console.log(error));
}
var promise = new Promise((r,j)=>{
setTimeout(()=>{
j('rejected');
},300)
})
process1();
process2();