Skip to content

Instantly share code, notes, and snippets.

@siemiatj
Created January 15, 2016 06:43
Show Gist options
  • Save siemiatj/ce2a881e0672d531d474 to your computer and use it in GitHub Desktop.
Save siemiatj/ce2a881e0672d531d474 to your computer and use it in GitHub Desktop.
Reject from promise is automatically treated as error in try/catch
function getFoo() {
return new Promise(function(resolve, reject) {
return reject(error);
});
}
try {
var x = getFoo();
} catch(error) {
console.error(error);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment