On 7 Mar 2008, at 08:02, Michael Daumling wrote:
This may sound like a stupid question, but...
Adding file and line info to an Error instance seems to be a good
thing.
Should the standard include two read-only properties "fileName" and
"line" that an implementation may choose to fill in during
construction,
and that return, say, the empty string and -1 if not supported?
SpiderMonkey and ExtendScript both support these properties.
Michael
I'm for this, and on a similar tact make it easier to subclass error
to create custom user Error classes. Currently in Spidermonkey you
have to jump through the following hoops to get an Error subclass with
filename and linenumber properties:
http://groups.google.com/group/mozilla.dev.tech.js-engine/browse_thread/thread/af195c5aafbfcb32
I forget all the problems, but from memory the main one is that:
MyError = function() {};
MyError.prototype = Error.prototype;
Doesn't do what you'd expect. And doing
MyError.prototype = new Error();
Is no good since then the filename and linenumber will be of that
line, not where you create the MyError instance.
Ash
_______________________________________________
Es4-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es4-discuss