[whatwg] window.onerror -ancient feature needs upgrade
Mike Wilson
mikewse at hotmail.com
Tue Nov 25 01:19:40 PST 2008
[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
More information about the whatwg
mailing list