Decorate the $exceptionHandler service


app.config(function($provide) {
  $provide.decorator("$exceptionHandler", function($delegate, $window) {
    return function(exception, cause) {

      // keep the original logic
      
      $delegate(exception, cause);

      var data = {
        message: exception.stack || exception.message || exception || '',
        cause: cause || '',
        errorUrl: $window.location.href,
        clientSideDate: new Date().getTime()
      }
      // Bypassing angular's http abstraction to avoid infinite exception loops

      $http('POST', '/errors', angular.toJson(data),
        angular.noop, { 'content-type': 'application/json' });
    };
  });
})