Generally it is not good idea to throw exception in event handler.
However people are lazy and bugs happen, so let's see out chances in this situation.
xhr.onreadystatechange=function(){throw new Error();}
MSIE and FF supports window.onerror event, so uncought exceptions can end up in 
this global handler.
All browsers support some sort of "display JavaScript errors" but usually well hidden 
as small icon on status bar (MSIE) or deeply in menus (other browsers). 
Uniform handling is almost impossible. The very first idea was to rely on 
window.error in MSIE an FF and call window.onerror explicitly in 
other browsers (even if the browser does not support this error you can define 
window.onerror=function... 
and call it using window.onerror(msg,..,...) syntax.
However situation is even worse.
- FF 3.5.6 works fine, ewrror thrown, ends in window.onerror as expected.
 - MSIE 7.0 NativeXHR + 200 response - works fine
 - MSIE 7.0 NativeXHR + conditional request + 304 response - exception lost, window.onerror not called
 - MSIE 7.0 NativeXHR + cached version not tested byt expected - exception lost, window.onerror not called
 - FF 3.6 exception lost, window.onerror not called
 
- exception being thrown out of boundaries of the handler (eaten exception)
 - even if thrown to be catched somewhere (missing window.onerror concept)
 


No comments:
Post a Comment