I'm trying to figure out a good way to say "Do all of these things, but bail in the case that any of them fails"
What I have right now:
var defer = $q.defer();
this
.load( thingy ) // returns a promise
.then( this.doSomethingA.bind( this ) )
.then( this.doSomethingB.bind( this ) )
.then( this.doSomethingC.bind( this ) )
.then( this.doSomethingD.bind( this ) )
.then( function(){
defer.resolve( this );
} );
;
return defer.promise;
What I ultimately want is to somehow catch any error on that chain so I can pass it on to the defer
promise above. I don't particularly care if the syntax is kept similar to what I have above.
Or even if anyone can just tell me how to stop the above chain.