nbdd0121 / es-error-stack

ECMAScript Error Stacktrace Proposal
5 stars 1 forks source link

Object representation should be primary #1

Open erights opened 8 years ago

erights commented 8 years ago

At https://mail.mozilla.org/pipermail/es-discuss/2016-February/045493.html I write:

Unless the object representation is primary, we will need to agree on comprehensive escaping rules, and corresponding parsing rules, so that these stack strings can be unambiguously scraped even when file names and function names contain parens, slashes, angle brackets, at-signs, spaces, etc. Therefore, we should focus on the object representation first.

Your object representation above looks like a good start. It is similar to the extended Causeway stack format I mentioned earlier

    stacktrace ::= {calls: [frame*]};
    frame ::= {name: functionName,
               source: source,
               span: [[startLine,startCol?],[endLine,endCol?]?]};
    functionName ::= STRING;
    startLine, startCol, endLine, endCol ::= INTEGER
    source ::= STRING | frame;

with the following differences:

The proposed[1] API is:

System.getStack(err) -> stack-representation
Reflect.stackString(stack-representation) -> stack-string
System.getStackString(err) -> stack-string

where getStackString is just the obvious composition of getStack and stackString.

[1] Hopefully https://github.com/tc39/ecma262/issues/395 will resolve in time that none of these need to be rooted in globals.

nbdd0121 commented 8 years ago

At https://mail.mozilla.org/pipermail/es-discuss/2016-February/045494.html I wrote: