standardizing Error.stack or equivalent

Jason Orendorff jason.orendorff at gmail.com
Thu Mar 27 11:29:19 PDT 2014


Not formally, but it's straightforward:

At the time you call eval() or Function(), we capture the string
    fileName + " line " + lineNumber + " > eval"
or "> Function" if you're calling Function. We use that string as the
fileName for the dynamic eval or Function code. This affects both
err.fileName and err.stack.

This implies these synthetic fileNames can nest. You can end up with a
stack like:

    js> try { eval("eval('FAIL')"); } catch (x) { print(x.stack); }
    @typein line 2 > eval line 1 > eval:1:1
    @typein line 2 > eval:1:1
    @typein:2:7

I think the extended format was added in this bug:
  https://bugzilla.mozilla.org/show_bug.cgi?id=332176

-j

On Thu, Mar 27, 2014 at 1:37 PM, Mark S. Miller <erights at google.com> wrote:
> Is this extended format documented anywhere?
>
>
> On Thu, Mar 27, 2014 at 10:36 AM, Jason Orendorff
> <jason.orendorff at gmail.com> wrote:
>>
>> On Thu, Mar 27, 2014 at 12:31 PM, Mark Miller <erights at gmail.com> wrote:
>> > Mozillians, why did you add this extra information?
>>
>> Well... if the point of Error.stack is to provide diagnostic
>> information for exceptions, for the purpose of debugging, this
>> information is critical.
>>
>> Without this, eval() or Function() often won't appear on the stack
>> anywhere. What we were doing before didn't reveal that eval or
>> Function was involved at all. It was misleading and unhelpful.
>>
>> -j
>
>
>
>
> --
>     Cheers,
>     --MarkM


More information about the es-discuss mailing list