3

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.

4
  • can you show us some code what you wrote?As per error it shows Argument 'TackleController' is not a function, got undefined Commented Nov 24, 2014 at 3:38
  • I didn't define TackleController at all. My point in showing the errors was that they do not indicate at which line I tried to reference an undefined variable. That's what I want to get, the actual line number that an error is at. I don't care about this specific error because I already know why it got thrown. Commented Nov 24, 2014 at 3:47
  • still no clue without seen the code I can't answer Commented Nov 24, 2014 at 12:17
  • The ironic part is that you're complaining about the lack of shown source code...which is what OP is complaining about as well. Commented Dec 4, 2015 at 20:05

1 Answer 1

0

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

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

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.