I'm can't figure out how to deal with networking errors when using XMLHttpRequest. That interface provides a way to get HTTP-related status (404, 200, 500, etc.) but that assumes you are able to reach the server in the first place. I want to catch conditions like the host being down, or the hostname not being resolvable, or the connection being refused.

This is sort of a repost. I asked about this in npm.xml, but after doing some digging around and experimenting, I thought I'd wander over and ask here. I'm working on chrome, by the way, and am using Javascript.

Here's a rundown on what I tried. So far, I've concentrated on accessing the XMLHttpRequest's channel attribute in various ways, none successful:

1.) I notice that "channel" becomes null after an unsuccessful connection attempt (one of the error conditions listed above).

2.) I tried to QueryInterface "channel" to something that sounded interesting (an nsITransportRequest) because that interface had a reference to an nsITransport, which in turn had access to some low-level status. Unfortunately, accessing "Components.interfaces.nsITransportRequest" results in an "undefined property" exception. Blind alley, I guess.

3.) RDF datasource objects implement an interface called nsIRDFXMLSink which has a method called addXMLSinkObserver. Using this you can add a RDFSinkObserver object that implements a bunch of callbacks for errors and other events. XMLHttpRequest, on the other hand, implements the nsIRequestObserver interface, which is different. Can you do something similar to the RDF case: replace the nsIRequestObserver with an object containing some callbacks?

I'm afraid I've become lost in all the interfaces and attributes. Help!

Chuck
_______________________________________________
Mozilla-netlib mailing list
[EMAIL PROTECTED]
http://mail.mozilla.org/listinfo/mozilla-netlib

Reply via email to