Skip to content

Instantly share code, notes, and snippets.

@gkatsev
Last active December 20, 2015 13:59
Show Gist options
  • Save gkatsev/6143193 to your computer and use it in GitHub Desktop.
Save gkatsev/6143193 to your computer and use it in GitHub Desktop.
function foo(id) {
var deferred = q.defer();
bar(id)
.then(function(obj) {
var anotherDeferred = q.defer();
log('fail');
if (obj) {
deferred.reject(new Error('no obj'));
anotherDeferred.reject(new Error('no obj'));
return anotherDeferred.promise;
}
anotherDeferred.resolve();
return anotherDeferred.promise;
})
.then(function() {
log('we got here anyway');
})
.reject(function(error) {
log(error);
deferred.reject(error);
});
return deferred;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment