Skip to content

Instantly share code, notes, and snippets.

@zen0wu
Created July 7, 2019 04:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zen0wu/c30b9f7a6a868741eac1ec7f5ab37f09 to your computer and use it in GitHub Desktop.
Save zen0wu/c30b9f7a6a868741eac1ec7f5ab37f09 to your computer and use it in GitHub Desktop.
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