title: AngularJS - fail resilence on $q.all()
body: <p>I'm trying to fill some local data resolving a series of remote calls.<br>
  When every promise is resolved, I load the data and proceed.</p>
  
  <p>The method <code>$q.all( [] )</code> does exactly this:</p>
  
  <pre><code>        $q.all([
              this.getUserInfo(11)
                  .then(function (r) {
                      results.push(r)
                  }),
  
              this.getUserConns()
                  .then(function (r) {
                      results.push(r)
                  }),
  
              this.getUserCtxs()
                  .then(function (r) {
                      results.push(r)
                  })
          ])
          .then(function () {
              console.log(results)
          })
  </code></pre>
  
  <p><br>
  Problem is, this code is not resilient.<br>
  If any of these call fails, nobody gets the fish!  </p>
  
  <p>Wrapping the calls in a try/catch statement, simply causes <code>$q.all()</code> to entirely ignore the entry, even when not failing (note the console.log in the func)...</p>
  
  <pre><code>        $q.all([
              this.getUserInfo2(11)
                  .then(function (r) {
                      results.push(r)
                  }),
  
              function () {
                  try {
                      this.getUserGroups()
                          .then(function (r) {
                              console.log(r)
                              results.push(r)
                          })
                  }
                  catch (err) {
                      console.log(err)
                  }
              },
          ])
          .then(function () {
              console.log(results)
          })
  </code></pre>
  
  <p>Output:</p>
  
  <blockquote>
    <blockquote>
      <p>[Object]</p>
    </blockquote>
  </blockquote>
  
  <p><br>
  <strong>Any hint on how I could wrap this to be resilient?</strong>
  <hr>
  Thanks to @dtabuenc, I've gone one step further.
  Implementing the error callback, I can avoid the breaking of the chain, and push the values of the resolved promises.    </p>
  
  <p>However, a nasty Exception is still displayed on the console...
  How can I get rid of that if I cannot try/catch on async requests?</p>
  
  <p><strong>Caller code</strong></p>
  
  <pre><code>    return $q.all([
  
              this.getUserInfo(user_id)
                  .then(function (r) {
                      results['personal_details'] = r
                  }),
  
              this.getUserConns()
                  .then(
                      function (r) {
                      results['connections'] = r
                      },
                      function(err) {
                          console.log(err)
                      })
  
          ])
          .then(function () {
              return (results)
          })
  </code></pre>
  
  <p><strong>Callee code (inject with an exception)</strong></p>
  
  <pre><code>    getUserConns: function() {
  
          return __doCall( ws.getUserConnections, {} )
              .then( function(r) {
  
                  // very generic exception injected
                  throw new Error
  
                  if (r &amp;&amp; r.data['return_code'] === 0) {
                      return r.data['entries']
                  }
                  else {
                      console.log('unable to retrieve the activity - err: '+r.data['return_code'])
                      return null
                  }
              })
      },
  </code></pre>