ES6 and Error Object properties
P T Withington
ptw at pobox.com
Wed Nov 4 12:04:56 PST 2009
Sure would be nifty to have #file and #line directives, now that
Javascript is the new C.
FWIW, OpenLaszlo generates annotations like so:
Filename, line, column:
/* -*- file: lpp-8534.lzx#10.7 -*- */
Same file, but line numbering needs to be reset (because output has
more or less lines corresponding to source):
/* -*- file: #15 -*- */
No corresponding source file (i.e., generated code follows):
/* -*- file: -*- */
I can see merits to one gigantic comment up front with a mapping table
ala Caja, but we found interspersing them worked better for humans
staring at Javascript "assembly" in a Javascript debugger.
IWBNI @sourceurl could be expanded in some form to work with loaded
files...
On 2009-11-04, at 14:39, Patrick Mueller wrote:
> Coincidently, I posted a blog entry on SyntaxError and eval()
> yesterday:
>
> http://pmuellr.blogspot.com/2009/11/evil-eval.html
>
> On Nov 4, 2009, at 11:10 AM, Kevin Curtis wrote:
>
>> This has probably been chewed over but -
>>
>> The ES5 spec defines 'name' and 'message' as properties of the
>> Error -
>> and ReferenceError, SyntaxError etc - objects.
>>
>> Currently engines have useful additional non-standard properties:
>> Mozilla - fileName, lineNumber and stack.
>> V8 - stack (and type, arguments). (The string returned by 'stack' is
>> not in the same format as Mozilla).
>> JSC - line, sourceId, sourceURL, expressionBeginOffset,
>> expressionCaretOffset ,expressionEndOffset - and a few others for
>> Statement errors.
>>
>>
>> Any chance for ES6 on standardizing Error object property/ies which
>> report back the error location.
>>
>> Maybe a property 'location' on the Error object which returns an
>> object. e.g
>> e.location ->
>> {fileName:<filename>, pos: <character posNumber>, line:<lineNumber> ,
>> lineEnd:<lineNumber>, col:<colNumber> , colEnd:<colNumber>, stack:
>> <stackString>}
>>
>> With maybe pos and line being mandatory properties and the other
>> properties set if they can be set.
>>
>
> Patrick Mueller - http://muellerware.org/
>
>
>
>
> _______________________________________________
> es-discuss mailing list
> es-discuss at mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss
More information about the es-discuss
mailing list