Stop a promise chain without using reject in angular

It doesn't happen very often, but, sometimes you need to stop the execution of the consecutive thens of a promise.

After 5 minute googling the standard solutions seems to be to simply use reject in the promise. However this is the same as throwing an error and, hence, has the side effect of triggering the the error handlers in the chain, namely the catch callbacks.

What if you wanted to avoid calling any catch callback, but at the same time making sure that the chain of then execution is stopped? Is there a way to break the promise chain without using reject?

Fortunately, the designers of promises accounted for this scenario and there is a way to achieve this and it is very simple. All you have to do is to explicitly return null inside of a then callback. Something like this in javascript:

myPromise  
    .then(function(){
         //... do your stuff
         return null;
    })
    .then(function(){
         //... this will never get executed
    })
And how do we do this in angular?

Now, the promise library from angular ($q) makes this a bit more tricky.

For some reason that I don't understand returning null won't be enough. Instead you need to return another new promise whose resolver returns null. And the way of doing this in javascript is:

$q(function(){return null;})

or in coffrescript

$q(->null)