title: Possibly unhandled rejection in Angular 1.6
body: <p>I have a code with AngularJS:</p>
  
  <pre><code>service.doSomething()
    .then(function(result) {
        //do something with the result
    });
  </code></pre>
  
  <p>In AngularJS 1.5.9 when I have error in the <code>.then()</code> section like:</p>
  
  <pre><code>service.doSomething()
    .then(function(result) {
        var x = null;
        var y = x.y;
        //do something with the result
    });
  </code></pre>
  
  <p>I'm getting clear error message:</p>
  
  <blockquote>
    <p>TypeError: Cannot read property 'y' of null</p>
  </blockquote>
  
  <p>But in version 1.6 with the same code I'm getting a different error:</p>
  
  <blockquote>
    <p>Possibly unhandled rejection: {} undefined</p>
  </blockquote>
  
  <p>I know that this is related to <a href="https://github.com/angular/angular.js/commit/c9dffde1cb167660120753181cb6d01dc1d1b3d0" rel="noreferrer">this change</a>, and the single solution is quite simple by adding <code>.catch()</code> block:</p>
  
  <pre><code>service.doSomething()
    .then(function(result) {
        var x = null;
        var y = x.y;
        //do something with the result
    })
    .catch(console.error);
  </code></pre>
  
  <p>Now I again have what I want:</p>
  
  <blockquote>
    <p>TypeError: Cannot read property 'y' of null</p>
  </blockquote>
  
  <p>But how to obtain the same result (more detailed error) for entire application without adding <code>.catch()</code> block in every single place?</p>
  
  <p>I tested the suggested solution to disable this by adding:</p>
  
  <pre><code>$qProvider.errorOnUnhandledRejections(false);
  </code></pre>
  
  <p>But with this the situation is even worse - I do not have ANYTHING in the console! The error is swallowed somewhere and not logged at all. I'm not sure is it a problem with AngularJS 1.6 or with my configuration.</p>
  
  <p>Do you have any ideas how to "restore" logging behavior from version 1.5.9?</p>
  
  <p><strong>EDIT:</strong></p>
  
  <p>Adding custom error handler:</p>
  
  <pre><code>.factory('$exceptionHandler', function($log) {
    return function(exception, cause) {
      $log.warn(exception, cause);
    };
  })
  </code></pre>
  
  <p>does not help at all. In the error handler I already receive the "wrapped" error.</p>