Created
July 7, 2019 04:32
-
-
Save zen0wu/c30b9f7a6a868741eac1ec7f5ab37f09 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function errorPromise() { | |
return new Promise((_resolve, _reject) => { | |
console.log('error coming up'); | |
throw new Error('oops'); | |
}); | |
} | |
function okPromise() { | |
return new Promise((_resolve, _reject) => { | |
console.log('ok'); | |
// _resolve('ok'); | |
setTimeout(() => _resolve('ok'), 0); | |
}); | |
} | |
async function cannotCatchError() { | |
try { | |
const p = okPromise(); | |
const p2 = errorPromise(); | |
// await Promise.all([p, p2]); | |
await p; | |
await p2; | |
} catch (e) { | |
console.log('caught', e); | |
} | |
console.log('done'); | |
} | |
cannotCatchError(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment