Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AngularJS - Disable $exceptionHandler

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.

like image 868
Roy Truelove Avatar asked Sep 12 '13 21:09

Roy Truelove


3 Answers

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.

like image 34
mems Avatar answered Nov 13 '22 03:11

mems


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.

like image 162
Roy Truelove Avatar answered Nov 13 '22 01:11

Roy Truelove


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.

like image 1
ovmjm Avatar answered Nov 13 '22 02:11

ovmjm