Skip to content

Instantly share code, notes, and snippets.

@deecewan
Created October 10, 2017 12:05
Show Gist options
  • Save deecewan/00594db6cf3d0b21b6356bc8b11fe7f9 to your computer and use it in GitHub Desktop.
Save deecewan/00594db6cf3d0b21b6356bc8b11fe7f9 to your computer and use it in GitHub Desktop.
(() => {
const myPromise = new Promise((res) => setTimeout(res, 10));
myPromise
.then(() => { throw new Error('shit\'s fucked'); })
.then(() => console.log('won\'t ever run'))
.catch(err => console.log('how is shit?', err))
.then(() => console.log('will run'))
.then(() => { throw new Error('some other error'); })
.then(() => console.log('won\'t run'))
.then(() => console.log('won\'t run'))
.catch((err) => {
if (err instanceof TypeError) {
// i can handle that
return console.log('typeerror', err);
}
throw err;
})
.then(() => console.log('won\'t run'));
})()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment