469,286 Members | 2,521 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,286 developers. It's quick & easy.

window.onerror handler and "throw new error" incompatible. Workaround?

I've been happily using a custom error handler of the following form for a
while now:

window.onerror = function(Message, URL, Line) { ... }

The current case is an intranet application (support for IE 6.x is the only
browser requirement) used by a small group of people. The custom error
handler presents information about the corporate help desk and allows the
user to email the information to the support team.

However I've noticed that errors thrown manually never appear to be caught.
For example the following error will never be displayed:

throw new Error("message")

Errors of this type are embedded in some of the libraries and components
that are used - changing them isn't an option.

Note that this is really an IE 6.x problem - IE 7 works as hoped (the
manually thrown error is displayed). Firefox also seems happy enough
(although I can't test it on this particular application).

In any case it's just plain annoying and I spend a few hours every few
months trying to come up with a low-impact workaround. I'd love some way to
modify the window.onerror handler to address it but the handler doesn't even
seem to be called (although if it's removed the manually thrown errors
appear as you'd expect).

Any ideas or (better yet) solutions? Right now I'm simply disabling the
generic error handler when in a special "debugmode"... but that still means
that the end users never see certain errors.

Thanks in advance.

Jim Davis
Oct 27 '06 #1
1 2618
Just answering my own question.

It turns out that window.onerror with a thrown new Error does work sometimes
in IE 6. The issue seems to occur with some combinations of the three
advanced settings for script errors (enable IE debugger, enable "other"
debugger and always throw script errors).

I've not nailed it down yet, but in some configurations it works, in other

Jim Davis

Oct 28 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Jaroslaw Zabiello | last post: by
15 posts views Thread by bill salkin | last post: by
10 posts views Thread by Paul Gorodyansky | last post: by
6 posts views Thread by sowencheung | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.