October 12th, 2009


Why even bother putting exceptions in the @#$%ing language if you can't catch them??

Q: When I run a Flex application in the debug flash player I get an exception pop up as soon as something unexpected happened. However when a customer uses the application he does not use the debug flash player. In this case he does not get an exception pop up, but he UI is not working.

So for supportability reasons, I would like to catch any exception that can happen anywhere in the Flex UI and present an error message in a Flex internal popup. By using Java I would just encapsulate the whole UI code in a try/catch block, but with MXML applications in Flex I do not know, where I could perform such a general try/catch.

A: There is no way to be notified on uncaught exceptions in Flex 3. Adobe are aware of the problem but I don't know if they plan on creating a workaround.

Furthermore, it's actually impossible to catch an error thrown from an event handler. I have logged a bug on the Adobe Bug System.

The only solution as it stands is to put try/catch in logical places and make sure you are listening to the ERROR (or FAULT for webservices) event for anything that dispatches them.


Edit: It's also worth noting that if you don't use the debug version of the flash player (and your customers almost certainly won't), then there's no guarantee you'll see exceptions even when they do occur. This has happened to me personally several times.
  • Current Music
    I Voted For Kodos - Please Die In A Fire