Skip to content

Instantly share code, notes, and snippets.

@pomle
Last active October 6, 2017 13:08
Show Gist options
  • Save pomle/85ce7a4ee069010a357f48d30888191d to your computer and use it in GitHub Desktop.
Save pomle/85ce7a4ee069010a357f48d30888191d to your computer and use it in GitHub Desktop.
function fail() {
return new Promise((resolve, reject) => {
reject(new Error('This failed'));
});
}
function doAction() {
return fail()
.catch(error => {
console.log('Arbitrarily chosen error logging the caller can not know about.');
});
}
doAction()
.then(result => {
// Will run
console.log('False positive success!');
})
.catch(error => {
// Will not run
console.error('An error happened but no one will ever now', error);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment