title: jQuery deferred: throw and catch an exception in the fail() callback
body: <p>I am trying to make an ajax request and throw an exception when it fails. Unfortunately I am not able to catch the exception. My code looks like this:</p>
  
  <pre><code>try {
      jQuery.ajax('http://www.someurlthatwillproduceanerror.com')
          .fail(function () {
              throw 'an exception';
          })
          .done(function () {
              console.log('ok');
          })
      ;
  } catch (e) {
      console.log(e);
  }
  </code></pre>
  
  <p>I would expect the code to catch the exception and log 'an exception' to the console. Instead I end up with an uncaught exception.</p>
  
  <p>Does anyone know how to handle exceptions in this case?</p>