W3C home > Mailing lists > Public > whatwg@whatwg.org > November 2008

[whatwg] window.onerror -ancient feature needs upgrade

From: Mike Wilson <mikewse@hotmail.com>
Date: Tue, 25 Nov 2008 10:19:40 +0100
Message-ID: <BAY116-DAV105D34F910545E0AB587ECA40B0@phx.gbl>
[didn't notice this discussion at the time]

Garrett Smith wrote on 20 August 2008 04:08
> On Tue, Aug 19, 2008 at 6:16 PM, Ian Hickson <ian at hixie.ch> wrote:
> > Is window.onerror not enough?
> 
> window.onerror would be sufficient if it:
>   * accepted an Error parameter.
>   * fired when an EventListener callback had an Error
>   * fired when a callback in setTimeout had an Error
> 
> But unfortunately, none of the above is true. At least some of it is
> true in some browsers.

A very nice improvement list! These are exactly the flaws I've been
hitting when trying to use window.onerror for something useful in
Ajax apps. Instead we have had to resort to "decorating" all event
handlers with try/catch logic.

> > I'm not sure I follow what the problem is here. Is this to 
> > aid debugging?
> 
> Yes. window.onerror seems useful for testing and debugging but leaves
> some to be desired.

The way we would have liked to use it is actually for fallback error
handling/presentation in Ajax apps. Ie, if you need custom error 
handling for some site function then implement it as try/catch in the
respective event handler, but if you just want error presentation with
standard recovery then let it bubble out to the "global" error 
handling in window.onerror.
Naturally, for this scenario it is also important with the Error 
parameter for onerror.

Best regards
Mike Wilson
Received on Tuesday, 25 November 2008 01:19:40 UTC

This archive was generated by hypermail 2.4.0 : Wednesday, 22 January 2020 16:59:07 UTC