title: How to assign multiple onError functions to a promise (returned by angular's $http.post)
body: <p>My AngularJS code needs to chain multiple <code>onSuccess</code>, <code>onError</code> functions to a promise returned by <code>$http.post</code></p>
  
  <pre><code>  var promise = $http.post(url);
       promise
        .then(
            /*success 1*/function () { console.log("success 1"); },
            /*error 1*/function () { console.log("error 1"); })
        .then(
            /*success 2*/function () { console.log("success 2"); },
            /*error 2*/function () { console.log("error 2"); });
  </code></pre>
  
  <p>The problem with above code is that it prints <code>error 1</code> > <code>success 2</code> when the HTTP response fails instead of <code>error 1</code> > <code>error 2</code>. </p>
  
  <p>I did some research on stackoverflow and found that when you have access to <code>$q</code> you can just do <code>$q.reject()</code> in <code>error 1</code> to trigger <code>error 2</code> but in my case i only have access to the promise returned by <code>$http.post</code>. So what do I do?</p>
  
  <p><strong>P.S.</strong> Of course, I can call <code>error2()</code> from inside of <code>error 1</code> but i want to chain them because it looks more readable and extensible.</p>
  
  <p>Any ideas?</p>