ShadowMage Posted April 15, 2010 Share Posted April 15, 2010 Ok, here's another quick question. Is it possible to get the line number where a function is called. For example: function aFunction() { if (condition) { //do something } else { throw "error line"+lineNumber; }}...function anotherFunction() { aFunction(); //Say this is line 47} Is there a function or a property to set the lineNumber variable in the first function equal to line 47, the line where aFunction is called? Link to comment Share on other sites More sharing options...
justsomeguy Posted April 15, 2010 Share Posted April 15, 2010 There's not an easy way to do that. You can look at the arguments variable inside a function to see what's available in there, or you can try to create a new error object and then check the properties of that. http://stackoverflow.com/questions/1340872...script-caller-sThere's also an example of printing a stack trace here:http://github.com/emwendelin/javascript-stacktrace Link to comment Share on other sites More sharing options...
ShadowMage Posted April 15, 2010 Author Share Posted April 15, 2010 Ok, thanks. I'll have a look at those and see what I can find.Edit:Well, I've looked at those links and did a little messing around with it, and this appears to be far more complicated than I had hoped for. Thanks for your time, jsg. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.