Warning: mysql_get_server_info(): No such file or directory in /homepages/13/d88087977/htdocs/liquid/wp-content/plugins/simple-tagging-plugin/simpletagging.php on line 299

Warning: mysql_get_server_info(): A link to the server could not be established in /homepages/13/d88087977/htdocs/liquid/wp-content/plugins/simple-tagging-plugin/simpletagging.php on line 299
Global Exception Handling in Flex | Liquidnight // Jörg Birkhold

Liquidnight // Jörg Birkhold

Direkt zum Inhalt springen

Liquidnight // Jörg Birkhold

Jörg Birkhold about iOS, Objective-C, Android, FlashPlatform, Multitouch, Flex, Air, 3d Interactive and Software Development


Global Exception Handling in Flex

Maybe someone also ran in the situation that your Flex Application is so big that you can’t be 100% sure that there is no uncatched Runtime Error.
This can get quickly ugly and your app will be reacting totally unpredictable. In the current state of the Flash Player there is no global exeption handling.
There is also a good post about that by Doug Mccune.

Using a try catch block everywhere in Flex it is not so easy because a lot of code is executed async by the callLaterDispatcher.
But after looking around a little I found a Variable in UIComponentGlobals.as called catchCallLaterExceptions.
If you set this to true the callLaterDispatcher will run inside a try catch block, and you can set a listener on the systemManager to catch the Error Event.
This is just little tested from my side so I can’t say for sure that it will work always correctly.

UIComponentGlobals.catchCallLaterExceptions = true;

The relevant Code is in UiComponent.as

private function callLaterDispatcher(event:Event):void
        // trace(">>calllaterdispatcher " + this);
        // At run-time, callLaterDispatcher2() is called
        // without a surrounding try-catch.
        if (!UIComponentGlobals.catchCallLaterExceptions)
        // At design-time, callLaterDispatcher2() is called
        // with a surrounding try-catch.
                var callLaterErrorEvent:DynamicEvent = new DynamicEvent("callLaterError");
                callLaterErrorEvent.error = e;

But this doesn’t work if there is a EventDispatcher involved in the callStack, as  Luke Bayes points out here.
If this is bug in the AVM2? I don’t think so…
But anyway this means it won’t work for events like creationComplete etc.

  1. ziv schrieb am Juni 18, 2009:

    Wow – it sound interesting!

    where did you add the:
    and what kind of exceptions it catch?



  2. joerg schrieb am Juni 18, 2009:

    It is in my Main Application. But you can add it anywhere where you can get a reference to the systemManager.
    It catches exeptions from actions which are called from the callLaterDispatcher() i.e. updateDisplayList() etc.


RSS-Feed für Kommentare dieses Beitrags.

Einen Kommentar hinterlassen

Erlaubte Tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Mehr Lesen