如何获取async函数中断的情况?
let doActions = async (actions) => {
let ret = null;
try {
for(let action of actions) {
ret = await new Promise((resolve, reject) => {
let result = action(ret);
if(typeof result == void 0 || result == false) reject();
resolve(result);
});
}
} catch(e) {
console.log(e);
}
return ret;
}
其中的action可能会返回一个promise,当这个promise reject的时候,如何获取到这个状态?
世界一绅士
9 years, 4 months ago