11

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 completely?

EDIT

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

1
  • Was your overridden $exceptionHandler similar to the one provided in ngMock? Commented Sep 12, 2013 at 21:30

3 Answers 3

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.

Sign up to request clarification or add additional context in comments.

1 Comment

This is one of the most frustrating parts of angularjs. I can't understand why it's even part of the library.
2

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.

1 Comment

Thanks mems - the problem with this is that it still code capture the error and rethrows it from the override. When that happens you loose the original stack trace.
1

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.