如果函数中抛出错误, throw new Error, 则相当于return Promise.reject(“error”)
案例 🔗
1
2
3
4
5
6
7
8
9
10
11
12
asyncfunctionthisThrows(){thrownewError("Thrown from thisThrows()");}try{thisThrows();}catch(e){console.error(e);}finally{console.log('We do cleanup here');}