title: How to properly break out of a promise chain?
body: <p>Based on the question here: <a href="https://stackoverflow.com/questions/27533826/jquery-chaining-and-cascading-thens-and-whens">jQuery chaining and cascading then&#39;s and when&#39;s</a> and the accepted answer, I want to break the promise chain at a point but haven't yet found the correct way. There are <a href="https://stackoverflow.com/questions/11302271/how-to-properly-abort-a-node-js-promise-chain-using-q">multiple</a> <a href="https://stackoverflow.com/questions/20714460/break-promise-chain-and-call-a-function-based-on-the-step-in-the-chain-where-it">posts</a> <a href="https://stackoverflow.com/questions/28572180/can-i-break-a-chain-early-with-bluebird-promises">about</a> this, but I am still lost.</p>
  
  <p>Taking the example code from the original question:</p>
  
  <pre><code>Menus.getCantinas().then(function(cantinas){ // `then` is how we chain promises
      Menus.cantinas = cantinas;
      // if we need to aggregate more than one promise, we `$.when`
      return $.when(Menus.getMeals(cantinas), Menus.getSides(cantinas));
  }).then(function(meals, sides){ // in jQuery `then` can take multiple arguments
      Menus.sides = sides; // we can fill closure arguments here
      Menus.meals = meals;
      return Menus.getAdditives(meals, sides); // again we chain
  }).then(function(additives){
      Menus.additives = additives;
      return Menus; // we can also return non promises and chain on them if we want
  }).done(function(){ // done terminates a chain generally.
       // edit HTML here
  });
  </code></pre>
  
  <p>How would I break the chain if <code>cantinas.length == 0</code>? I would not want to get the meals, neither the additives, frankly I would want to call some kind of "empty result" callback. I have tried the following which is <strong>very ugly</strong> (but works...). Teach me the correct way. This still is a valid result, so not a "fail" per se, just empty result I would say.</p>
  
  <pre><code>var emptyResult = false;
  Menus.getCantinas().then(function(cantinas){
      Menus.cantinas = cantinas;
      if (cantinas.length == 0) {
        emptyResult = true;
        return "emptyResult"; //unuglify me
      }
      return $.when(Menus.getMeals(cantinas), Menus.getSides(cantinas));
  }).then(function(meals, sides){ 
      if (meals == "emptyResult") return meals;  //look at my ugliness...
      Menus.sides = sides;
      Menus.meals = meals;
      return Menus.getAdditives(meals, sides);
  }).then(function(additives){
      if (additives == "emptyResult") return additives;
      Menus.additives = additives;
      return Menus;
  }).done(function(){
     if (emptyResult)
       //do empty result stuff
     else
       // normal stuff
  });
  </code></pre>