admin管理员组

文章数量:1287254

I don't want $exceptionHandler to handle any exceptions - I want them to propegate up to the browser (primarily for IE testing in Visual Studio).

I'd tried overriding $exceptionHandler and simply rethrowing the error, which gives me the 10 iterations of $digest error (which makes sense).

How do I shut it off pletely?

EDIT

Unfortunately rethrowing the error doesn't solve the issue - IE only knows the error from the rethrow and not from source.

I don't want $exceptionHandler to handle any exceptions - I want them to propegate up to the browser (primarily for IE testing in Visual Studio).

I'd tried overriding $exceptionHandler and simply rethrowing the error, which gives me the 10 iterations of $digest error (which makes sense).

How do I shut it off pletely?

EDIT

Unfortunately rethrowing the error doesn't solve the issue - IE only knows the error from the rethrow and not from source.

Share Improve this question edited Sep 13, 2013 at 15:21 Roy Truelove asked Sep 12, 2013 at 21:19 Roy TrueloveRoy Truelove 22.5k21 gold badges115 silver badges154 bronze badges 1
  • Was your overridden $exceptionHandler similar to the one provided in ngMock? – Problematic Commented Sep 12, 2013 at 21:30
Add a ment  | 

3 Answers 3

Reset to default 8

After some research, this isn't possible. Angular catches their errors and then calls the exception handler explicitly - in many cases it does not just let the error propagate.

According to the documentation, it's possible:

angular.module('exceptionOverride', []).factory('$exceptionHandler', function () {
    return function (exception, cause) {
        exception.message += ' (caused by "' + cause + '")';
        throw exception;
    };
});

This example will override the normal action of $exceptionHandler, to make angular exceptions fail hard when they happen, instead of just logging to the console.

Try throwing the exception inside a window.setTimeout (not $timeout) delayed execution, this would allow you to escape the $digest black hole. But not sure it will preserve the stack-trace in IE.

本文标签: javascriptAngularJSDisable exceptionHandlerStack Overflow