title: AngularJS: Chaining promises ignore rejection
body: <p>I'm new to AngularJS and I would like to know why does AngularJS keeps going on the next chaining operation even if one of my previous chaining functions fails.</p>
  
  <pre><code>  // Manipulate data
    function manipulationData(data) {
      return data.total + 2;
    }
  
    /*
    * Begin chaining promises
    */
    var deferred = $q.defer();
  
    // JSON Request
    $http.get('/json_test.json')
  
    // If results is ok, then manipulate some data
    .then(function(results) {
      if(results.status == "ok") {
        return manipulationData(results);
      } else {
        deferred.reject("Some data error");
      }
    }, function(reason) {
      deferred.reject("Error request: " + reason);
    })
  
    // If manipulation is success
    .then(function(results) {
      if(results &gt; 5) {
        return $http.get('http://host.com/second');
      } else {
        deferred.reject("Error! Data is invalid");
      }
    }, function(reason) {
      deferred.reject("Error request: " + reason);
    })
  
    .then(function(result){
      return $http.get('http://host.com/second'); 
    })
    return deferred.promise;
  </code></pre>
  
  <p>For some reason, the application keeps executing all the function even if one of them failed. I want the operation to stop when the 1st promise is not working.</p>
  
  <p>For example, if second operation failed, it should throw the error "Some data error".</p>
  
  <p>Thank you</p>