By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
431,934 Members | 1,677 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 431,934 IT Pros & Developers. It's quick & easy.

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

P: n/a
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
Share this Question
Share on Google+
1 Reply


P: n/a
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
not.

Jim Davis

Oct 28 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.