function smartPromise(promise){ return promise.then(res=>([null,res])).catch((e)=>([e,null])); } async function task(){ const [errorA,fileA] = await smartPromise(readFileA()); if(errorA!==null){ return 'read file A error'; } const [errorB,fileB] = await smartPromise(readFileB()); if(errorB!==null){ return 'read file B error'; } return fileB }