ES6 and Error Object properties

Patrick Mueller pmuellr at yahoo.com
Wed Nov 4 12:11:34 PST 2009


Coincidently (!!!), I recently opened a feature request in WebKit on  
this topic, kind of:

	https://bugs.webkit.org/show_bug.cgi?id=30933

Not sure I'll have time to do anything about it, and surely won't  
without some kind of real framework helping out to add support on  
their end ...

BTW, I thought JavaScript was the new assembler, not the new C.

On Nov 4, 2009, at 3:04 PM, P T Withington wrote:

> 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/






More information about the es-discuss mailing list