Closed Bug 344517 Opened 18 years ago Closed 12 years ago

Enable linenumber and filename in error console for extended errors

Categories

(Core :: XPConnect, enhancement)

enhancement
Not set
normal

Tracking

()

RESOLVED DUPLICATE of bug 119719

People

(Reporter: com, Unassigned)

References

(Blocks 1 open bug)

Details

(Keywords: testcase)

Attachments

(1 file)

User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.0.3) Gecko/20060426 Firefox/1.5.0.3 Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.0.3) Gecko/20060426 Firefox/1.5.0.3 The Error Console shows the filename and line number of a normal javascript error. For example when a "throw new Error('my message')" is encountered in script. This is good! However I would also like to be able to see a filename and line number of throw errors that are extended from Error using the prototype chain. This is an example of a extended error: ***** function MyError(message) { this.message = message; } MyError.prototype = new Error() ***** Normally the call method is used in the MyError constructor Error.call(this, message) to initialize the super members. However the ECMAScript specification has been correctly implemented so that this will return a new Error instance instead. Also the inheritance can be done smarter without calling the constructur directly, but that is irrelevant to this feature request. Even when a MyError instance has a filename and linenumber property nothing is shown about it in the error console. It is unclear to me what is the requirement is for the Error Console to show that useful information. I have two alternatives how to implement this: 1) If something is thrown and instanceof Error is true (such as for MyError instances), then "enhance" the error object by setting the linenumber and filename properties in that object. Let the Error Console show this information. 2) Show the linenumber and filename information in the Error Console when the error object has a linenumber and filename property. And provide and API to manually retrieve this information (from a stack?) and set it when constructing your custom error object. Reproducible: Always
Attached file testcase
You can add a customized toString to your custom Error and get the result you want.
Component: Error Console → XPConnect
Product: Firefox → Core
QA Contact: error.console → xpconnect
Blocks: 435025
Keywords: testcase
Status: UNCONFIRMED → NEW
Ever confirmed: true
OS: Windows XP → All
Hardware: PC → All
Version: unspecified → Trunk
It needs to show a line number whenever there's a syntax based error: Warning: Expected ':' but found '='. Declaration dropped. Source File: http://www.tripro.org/19th-season/closed-curtains.html This tells me it wants one of the 60 ='s in that file to be a colon instead. Better than nothing, but it would be really helpful if it would point to the exact one it's unhappy about...
1) If something is thrown [...] "enhance" the error object by setting the linenumber and filename properties in that object. Let the Error Console show this information. This is bug 119719. > 2) Show the linenumber and filename information in the Error Console when the > error object has a linenumber and filename property. > And provide and API to manually retrieve this information (from a stack?) > and set it when constructing your custom error object. This works currently in Firefox: // retrieving: var {message, fileName, lineNumber} = new Error(); console.log(fileName, lineNumber); // throwing an error with custom location information: throw new Error("test", "filename.html", 200); PS. the issue in comment 2 is unrelated and probably is bug 261337.
Status: NEW → RESOLVED
Closed: 12 years ago
Resolution: --- → DUPLICATE
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: