URLLoader stream error handling
Actually, this has to do with asynchronous error handling, the URLLoader is just a common example of it.
Basically, since the call is async a try..catch..finally block won’t do you a beans bit of good. It takes a while for the loader to determine the url is bad and then it dispatches the IO_ERROR event.
What this means to your app is that if you don’t listen and handle this event the application will throw ugly errors.
To handle this do something along the lines of:
var loader:URLLoader = new URLLoader();
loader.addEventListener(IOErrorEvent.IO_ERROR, catchIOError);
function catchIOError(event:IOErrorEvent){
trace(”Error caught: “+event.type);
}
loader.load(new URLRequest(”Invalid XML URL”));
trace(”Continuing with script…”);
Leave a Reply