Reputation: 125
I'm trying to get stack traces in Angular which tell me where I went wrong. Instead, I simply get a list of where the error propagated through Angular. Sometimes the error message helps, but not always, but that's beside the point for me: I want to know the exact line number, as well as the file name, where my code bugged out. For example, here is a typical Firebug message:
Error: [ng:areq] Argument 'TackleController' is not a function, got undefined http://errors.angularjs.org/1.3.3/ng/areq?p0=TackleController&p1=not%20a%20function%2C%20got%20undefined minErr/< @http:// localhost:63342/fishing/bower_components/angular/angular.js:63:12 assertArg@http:// localhost:63342/fishing/bower_components/angular/angular.js:1560:1 assertArgFn@http:// localhost:63342/fishing/bower_components/angular/angular.js:1570:1 $ControllerProvider/this.$get< /<@http:// localhost:63342/fishing/bower_components/angular/angular.js:8347:9 nodeLinkFn/<@http:// localhost:63342/fishing/bower_components/angular/angular.js:7517:34 forEach@http:// localhost:63342/fishing/bower_components/angular/angular.js:330:11 nodeLinkFn@http:// localhost:63342/fishing/bower_components/angular/angular.js:7504:11 compositeLinkFn@http:// localhost:63342/fishing/bower_components/angular/angular.js:7003:13 compositeLinkFn@http:// localhost:63342/fishing/bower_components/angular/angular.js:7006:13 publicLinkFn@http:// localhost:63342/fishing/bower_components/angular/angular.js:6882:30 bootstrapApply/< @http:// localhost:63342/fishing/bower_components/angular/angular.js:1439:11 $RootScopeProvider/this.$get< /Scope.prototype.$eval@http:// localhost:63342/fishing/bower_components/angular/angular.js:14204:16 $RootScopeProvider/this.$get< /Scope.prototype.$apply@http:// localhost:63342/fishing/bower_components/angular/angular.js:14302:18 bootstrapApply@http:// localhost:63342/fishing/bower_components/angular/angular.js:1437:9 invoke@http:// localhost:63342/fishing/bower_components/angular/angular.js:4129:14 bootstrap/doBootstrap@http:// localhost:63342/fishing/bower_components/angular/angular.js:1435:1 bootstrap@http:// localhost:63342/fishing/bower_components/angular/angular.js:1455:1 angularInit@http:// localhost:63342/fishing/bower_components/angular/angular.js:1349:5 @http:// localhost:63342/fishing/bower_components/angular/angular.js:25746:5 trigger@http:// localhost:63342/fishing/bower_components/angular/angular.js:2720:7 createEventHandler/eventHandler@http:// localhost:63342/fishing/bower_components/angular/angular.js:2990:9
In this case, the problem is that I referenced a controller in my HTML which I hadn't defined; I'm posting this as an example of what I mean, not because I want help with the problem. I'm guessing it's because Firebug automatically truncates the stack trace at 20 errors?? But how could I change that?
P.S. I'm a noob to Angular. If this answer is duplicated somewhere else, please, please, actually link me to the question, instead of hamhandedly deleting the question.
Upvotes: 3
Views: 617
Reputation: 24617
Use window.onerror
to get the specifics of unhandled exceptions:
window.onerror = function (message, url, lineNo)
{
console.log('Error: ' + message + '\n' + 'Line Number: ' + lineNo);
return true;
}
console.log(window);
console.log(1=2);
References
Upvotes: 0