I am building an angular web application and I am wanting to send any javascript exceptions and callstacks from the client to the server for logging. In chrome and firefox I am able to get the callstack by looking at the exception.stack property, but this value is not available when using IE. Here is a code example from my angular controller:
function LogTestController($scope) {
$scope.TestError = function () {
callError1();
}
function callError1() {
callError2();
}
function callError2() {
var x = y;
}
};
And here is the exception.stack from chrome:
"ReferenceError: y is not defined
at callError2 (http://localhost:85/App/Offer/OfferController.js:16:17)
at callError1 (http://localhost:85/App/Offer/OfferController.js:12:9)
at Scope.LogTestController.$scope.TestError (http://localhost:85/App/Offer/OfferController.js:8:9)
at $parseFunctionCall (http://localhost:85/Scripts/angular.js:12345:18)
at ngEventDirectives.(anonymous function).compile.element.on.callback (http://localhost:85/Scripts/angular.js:21435:17)
at Scope.$get.Scope.$eval (http://localhost:85/Scripts/angular.js:14401:28)
at Scope.$get.Scope.$apply (http://localhost:85/Scripts/angular.js:14500:23)
at HTMLButtonElement.<anonymous> (http://localhost:85/Scripts/angular.js:21440:23)
at HTMLButtonElement.jQuery.event.dispatch (http://localhost:85/Scripts/jquery-1.9.1.js:3074:9)
at HTMLButtonElement.jQuery.event.add.elemData.handle (http://localhost:85/Scripts/jquery-1.9.1.js:2750:46)"
Which is very helpful in debugging. But IE does not have the extension.stack property when the error occurs inside of the angular controller.
However if I force the same error in IE when it is not inside an angular controller then there is a value for exception.stack. Here is an example of that code:
<script type="text/javascript">
try {
first();
} catch (exception) {
var trace = exception.stack;
};
function first() {
second();
};
function second() {
var x = y;
}
</script>
In IE the exception.trace is as follows:
"ReferenceError: 'y' is undefined
at second (http://localhost:85/App/logtest.html:20:13)
at first (http://localhost:85/App/logtest.html:16:13)
at Global code (http://localhost:85/App/logtest.html:10:13)"
I have also tried to use stacktrace.js to get the callstack from IE, but this library is reliant on the exception.stack value to be present.
Could somebody please help me understand why this is acting differently when inside an angular controller and how to get the stack trace from IE inside the angular controller?
Thanks