Skip to content

Instantly share code, notes, and snippets.

@domenic
Forked from gkatsev/gist:6143193
Last active December 20, 2015 13:59
Show Gist options
  • Save domenic/6143202 to your computer and use it in GitHub Desktop.
Save domenic/6143202 to your computer and use it in GitHub Desktop.
function foo(id) {
return bar(id).then(function (obj) {
if (!obj) {
throw new Error('no obj');
}
return obj; // pass it through
}).then(
function (obj) {
console.log('we got here, and have an obj; passing it through');
return obj;
},
function (err) {
console.log('we got an error; re-throwing it');
throw err;
}
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment