ES4 draft: Error classes

Lars Hansen lhansen at adobe.com
Thu Mar 20 09:27:02 PDT 2008


> -----Original Message-----
> From: P T Withington [mailto:ptwithy at gmail.com] On Behalf Of 
> P T Withington
> Sent: 20. mars 2008 07:41
> To: Lars Hansen
> Cc: es4-discuss Discuss
> Subject: Re: ES4 draft: Error classes
> 
> +1 to Lars Error context/backTrace proposal.
> 
> Can we also have something like #file and #line, so that the 
> various Javascript translators (ours, Dojo, various 
> compressors, etc.) can relate context back to the original 
> source, rather than the executed source?

Strawman proposal that avoids compounding our syntax woes.

Syntax:

A comment of this form preceded on the same line only by whitespace:

/**es:context=<scheme>;<data>;<line>*/

Space characters are not allowed anywhere except within <scheme> and
<data>, where it is interpreted literally.  Line terminators are not
allowed anywhere.  Line terminator characters in scheme and data should
be encoded using \x or \u syntax.


Semantics:

The meaning of scheme, data, and line are as for the context/backTrace
proposal.  The intent is that the values provided here override the
values that would be provided by the implementation in a source context
object.

A value for scheme, data, and line field must only be provided if values
are provided for the fields to its left.  Field values default to the
values from the previous instance of the directive.  Initial fields
values are the scheme and data the implementation would report absent
any annotation, and a line of 1.  


Conformance:

An ES4 implementation is free not to support this facility at all.

To support this facility means to understand the directives and to
report the values provided in the directives in error messages and in
the context/backTrace facility, if that is supported.


Example:

  /**es:context=file name;test.es;1*/
  /**es:context=;;7*/


--lars



More information about the Es4-discuss mailing list