On Tue, Mar 22, 2011 at 12:07 PM, Joshua Bell <j...@lindenlab.com> wrote:

> I was noodling with a (toy) compiler-to-JS for a (dead) language that
> supports error handlers for two boundary conditions - stack depth exceeded &
> out of memory - and noticed that the relevant behavior in JS is not standard
> across browsers. Has there been any discussion around standardization of
> errors thrown when limits of the script execution environment are hit?
> (Searching the archives didn't yield hits, but my search-fu may be weak
> today.)
>
> From briefly testing the boxes on my desk:
>
> stack depth:
> function a() { return a() + 1; } a();
>
> * IE9: Error, message: 'Out of stack space'
> * Firefox 4: InternalError, message: 'too much recursion'
> * Safari 5: RangeError, message 'Maximum call stack size exceeded'
> * Chrome 10: RangeError, message: 'Maximum call stack size exceeded', type:
> 'stack_overflow'
> * Opera 11: Error, message: 'Maximum recursion depth exceeded'
>

RangeError makes most sense here, imo. It does after all "indicates a
numeric value has exceeded the allowable range" (15.11.6.2) even if this
"numeric value" is something internal. Standardizing (or agreeing upon)
RangeError across implementations wouldn't solve much of course, since it
could be RangeError caused any of the other cases where RangeError occurs.
Parsing message for "stack" or "recursion" would help, but that's just ugly
and fragile.

Firefox's InternalError looks like something non-standard. I wonder why they
don't just throw Error.

[...]

-- 
kangax
_______________________________________________
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to