1

I am occasionally getting flash popup this error:

Error #2044: Unhandled error:. text=

My code is here:

    private var _myLoader:URLLoader = new URLLoader();

    public function load():void {       
        var finalURL = http://xxxxx.com/service_staging.php/next;

        var myRequest:URLRequest = new URLRequest(finalURL);

        // add event listeners
        this._myLoader.addEventListener(Event.COMPLETE, this._completeHandler);
        this._myLoader.addEventListener(Event.OPEN, this._openHandler);
        this._myLoader.addEventListener(ProgressEvent.PROGRESS, this._progressHandler);
        this._myLoader.addEventListener(SecurityErrorEvent.SECURITY_ERROR, this._securityErrorHandler);
        this._myLoader.addEventListener(HTTPStatusEvent.HTTP_STATUS, this._httpStatusHandler);
        this._myLoader.addEventListener(IOErrorEvent.IO_ERROR, _ioErrorHandler);

        try {
            this._myLoader.load(myRequest);
        } catch (_error:SecurityError) {
            Logger.error('JSONRequest.as - catch: A SecurityError has occurred:', _error);

        } catch(_error:IOErrorEvent) {
            Logger.error("JSONRequest.as - catch: IOErrorEvent:", _error);      

        } catch(_error:Error) {
            Logger.error("JSONRequest.as - catch: Error catch: ", _error);
        }
    }   

    //----------------------------------------------------------    

    private function _completeHandler(event:Event):void {           
        Logger.info('JSONRequest.as - _completeHandler()');


        Logger.info('this._myLoader.data', this._myLoader.data);

        // decode the object
        this._JSONObject = JSON.decode(this._myLoader.data);

        // dispatch the complete event
        this.dispatchEvent(new Event(Event.COMPLETE));
    }   

    //----------------------------------------------------------    

    private function _ioErrorHandler(_error:IOErrorEvent):void {
        Logger.error('JSONRequest.as - _ioErrorHandler()');

        dispatchEvent(new ErrorEvent(ErrorEvent.ERROR));
    }

    //----------------------------------------------------------

    private function _securityErrorHandler(_event:SecurityErrorEvent):void {
        Logger.info("JSONRequest.as - _securityErrorHandler(): ", _event);

        dispatchEvent(new ErrorEvent(ErrorEvent.ERROR));
    }

    //----------------------------------------------------------

    private function _openHandler(event:Event):void {
       Logger.info("JSONRequest.as - openHandler: " + event);
    }

    //----------------------------------------------------------

    private function _progressHandler(event:ProgressEvent):void {
        Logger.info("JSONRequest.as - progressHandler loaded:" + event.bytesLoaded + " total: " + event.bytesTotal);
    }

    //----------------------------------------------------------

    private function _httpStatusHandler(event:HTTPStatusEvent):void {
        Logger.info("JSONRequest.as - httpStatusHandler: " + event);
        Logger.info("status: " + event.status);
    }

    //----------------------------------------------------------

    public function get JSONObject():Object {
        return this._JSONObject;
    }

    //----------------------------------------------------------

I already handle if there is an issue getting the JSON data from the service but this error still seems to popup even though I am listening for it.

Any ideas would be greatly appreciated.

Thanks.

Oli
  • 47
  • 10
  • I'm having this same problem. I get an ioError popup, even though I'm handling all the events. This mainly happens for me when my internet connection dies (I'm testing a phone app and internet connections are spotty.) If anyone has solution, that'd be awesome! – DoomGoober Mar 20 '14 at 04:58

3 Answers3

2

You should add those listeners to _myLoader.contentLoaderInfo

this._myLoader.contentLoaderInfo.addEventListener(Foo.BAR, onFooBar);
scriptocalypse
  • 4,942
  • 2
  • 29
  • 41
  • Sorry - I should have included: private var _myLoader:URLLoader = new URLLoader(); I don't think URLLoader has contentLoaderInfo property. I am requesting and most of the time receiving a JSON object. – Oli Feb 17 '12 at 11:13
  • True @NicolasSiver, I must have been thinking of the Loader class rather than URLLoader. UncaughtErrorEvent was only available as of 10.1, which these days is relatively safe to assume as a baseline target but a couple of years ago might not have been (eg: Client requests FP 9 support) – scriptocalypse Mar 22 '14 at 19:58
1

To catch Unhandled IOError from URLLoader, you will need help of UncaughtErrorEvents:

loaderInfo.uncaughtErrorEvents.addEventListener(UncaughtErrorEvent.UNCAUGHT_ERROR, onGlobalError);


private function onGlobalError(e:UncaughtErrorEvent):void {
    e.preventDefault();
    trace("ERROR: " + e.toString());
}

//Trigget it...
var urlLoader: URLLoader = new URLLoader();
urlLoader.load(new URLRequest("somewhere/nowhere"));
Nicolas Siver
  • 2,875
  • 3
  • 16
  • 25
0

First of all, you need more information on this error ... the stack, the target of the ErrorEvent, etc..

Have you tried listening for UncaughtErrorEvent.UNCAUGHT_ERROR ? this is well explained in the following sample: http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/display/LoaderInfo.html#uncaughtErrorEvents and will allow you to catch any uncaught error, including unhandled ErrorEvent error and choose what to do it.

I would first recommend to get as much debug info as possible, to put a breakpoint var errorEvent:ErrorEvent = event.error as ErrorEvent;

Hopefully at this stage you'll have a fix, or at least a workaround (just add your error handling code after this breakpoint )

jauboux
  • 888
  • 6
  • 12