catch an exception from event handler

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Dormilich
    Recognized Expert Expert
    • Aug 2008
    • 8694

    catch an exception from event handler

    I was wondering, where I should catch an exception thrown from a function that is executed onevent…

    Code:
    // let’s say we have an AJAX call
    XHR.onreadystatechange = function ()
    {
    	if (4 === this.readyState) {
    		if (200 !== this.status) {
    			throw new Error("Error: " + this.statusText);
    		}
    		// process response
    	}
    };
    this would be OK for most GET/POST requests, but what to do if I make a HEAD request and get a 404 status?
  • Dormilich
    Recognized Expert Expert
    • Aug 2008
    • 8694

    #2
    well, at least I found that I can use the onerror event handler in Firefox.

    Comment

    Working...