title: AngularJS - Custom ExceptionHander not always working
body: <p>I've been trying to figure out how to send Client Side Exceptions to a Server for logging in an AngularJS application.</p>
  
  <p>I've followed the following steps posted here:
  <a href="http://www.bennadel.com/blog/2542-Logging-Client-Side-Errors-With-AngularJS-And-Stacktrace-js.htm" rel="nofollow">http://www.bennadel.com/blog/2542-Logging-Client-Side-Errors-With-AngularJS-And-Stacktrace-js.htm</a></p>
  
  <p>This is working fine for some errors but does not seem to catch exceptions thrown in my directives.</p>
  
  <p>E.g. my overriding of the exception handler:</p>
  
  <pre><code>app.provider("$exceptionHandler", {
      $get: function( errorLogService ) {
          return( errorLogService );
      }
  });
  </code></pre>
  
  <p>This works fine for exceptions from controllers but my directive just doesn't seem to go through my custom exception handler - it just logs directly to the console e.g.</p>
  
  <pre><code>app.directive('saveAndShowDialog', function() {
  
      function link(scope, element, attrs) {
  
          element.on('click', function(e) {
  
              var x = y; // forces exception
              scope.save();       
  
          });
      }
      return { restrict: 'A', link: link };
  })
  </code></pre>
  
  <p>;</p>
  
  <p>Can anyone give any direction as I've spent days on this and can't seem to get anywhere?</p>
  
  <p>Thanks,
  Kevin.</p>