This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.

Bug 26159 - request: caller's line number, filename, function name to assist in debugging
Summary: request: caller's line number, filename, function name to assist in debugging
Status: RESOLVED INVALID
Alias: None
Product: WHATWG
Classification: Unclassified
Component: JavaScript (show other bugs)
Version: unspecified
Hardware: PC Windows NT
: P2 enhancement
Target Milestone: Unsorted
Assignee: Mathias Bynens
QA Contact: sideshowbarker+javascript
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-06-21 08:11 UTC by Jim Michaels
Modified: 2014-06-21 12:54 UTC (History)
1 user (show)

See Also:


Attachments

Description Jim Michaels 2014-06-21 08:11:38 UTC
it would be nice if somehow js could let me know what line number and file from the caller caused the problem. it would make my debugging tremendously easier.
I think it would help a lot of people who develop web pages. something like this could be a predefined variable of some kind.
thanks.

this could mean examining the previous item on the call stack I suppose.

the idea is that, within the function call, I could maybe have access to the caller's function name, filename, and line number within the called function somehow.

as things are now, some debugger messages are pretty incomprehensible. I get messages about scripts I did not include on my site, and error messages I don't understand because they are specific to some package somewhere (and not documented well).

having these 3 pieces of information allows them, and me, to write my libraries in a way that helps the web programmer/designer fix problems without head scratching, they can get the error message form the console.log with the offending line# from the specific file they wrote, and jump right to it and fix the problem.

it's a time saver.
Comment 1 Jim Michaels 2014-06-21 08:12:05 UTC
change to enhancement.
Comment 2 Jim Michaels 2014-06-21 08:31:03 UTC
RE: comment 1 where it says 

"the idea is that, within the function call, I could maybe have access to the caller's function name, filename, and line number within the called function somehow." 

could be rewritten more clearly as 

"the idea is that, within the callee (the function called), I could have access to the caller's function name, filename, and line number within the called function somehow."

example: let's say in my file abc.html I am using the library xyz.js
<script src="/xyz.js"></script>
<script>
var x=xyz("123",5);
</script>

within xyz(), it could console.log() line 20 in file abc.html (or some other case may be that something is being called within a js file) and the calling function is an empty string since there is no parent.
Comment 3 Mathias Bynens 2014-06-21 12:54:52 UTC
This is outside the scope of the JavaScript / Web ECMAScript spec. See <http://javascript.spec.whatwg.org/#goals>.

To propose new features to the ECMAScript language, please file a bug on https://bugs.ecmascript.org/.