title: AngularJS - Promises rethrow caught exceptions
body: <p>In the following code, an exception is caught by the <strong>catch</strong> function of the $q promise:</p>
  
  <pre><code>// Fiddle - http://jsfiddle.net/EFpn8/6/
  f1().then(function(data) {
          console.log("success 1: "+data)
          return f2();
      })
      .then(function(data) {console.log("success 2: "+data)})
      .catch(function(data) {console.log("error: "+data)});
  
  function f1() {
      var deferred = $q.defer();
      // An exception thrown here is not caught in catch
      // throw "err";
      deferred.resolve("done f1");        
      return deferred.promise;
  }
  
  function f2() {
      var deferred = $q.defer();
      // An exception thrown here is handled properly
      throw "err";
      deferred.resolve("done f2");        
      return deferred.promise;
  }  
  </code></pre>
  
  <p>However when I look in the console log output I see the following:</p>
  
  <p><img src="https://i.stack.imgur.com/hExUq.png" alt="enter image description here"></p>
  
  <p>The exception was caught in Angular, but was also caught by the error handling of the browser. This behavior does reproduce with Q library.</p>
  
  <p>Is it a bug? How can I truly catch an exception with $q?</p>