Flex Error Handling Example
Category: Flex Error | 2,783 views | 2 Comments
This example is associated with the blog “Dustin’s Software
Cogitations and Speculations.”
The Flash Players, regular and debugger, can be downloaded
at http://www.adobe.com/support/flashplayer/downloads.html. –>
<mx:Script>
import mx.utils.ObjectUtil;
/**
* Test Flex exception handling.
*/
public function testException():void
{
try
{
intentionallyThrowException();
}
catch (error:Error)
{
stackTraceText.text = ObjectUtil.toString(error.getStackTrace());
messageText.text = error.message;
toStringText.text = error.toString();
nameText.text = error.name;
errorIdText.text = String(error.errorID);
}
finally
{
// I get called whether an exception is caught or not.
}
}
/**
* Intentionally throw an exception for use in Flex exception
* testing.
*/
public function intentionallyThrowException():void
{
throw new SyntaxError(”That was some bad syntax!”);
}
</mx:Script>
<mx:VBox id=”mainDisplay”>
<mx:Form>
<mx:FormItem id=”stackTraceItem” label=”Exception Stack Trace”>
<mx:Text id=”stackTraceText” />
</mx:FormItem>
<mx:FormItem id=”messageItem” label=”Message”>
<mx:Text id=”messageText” />
</mx:FormItem>
<mx:FormItem id=”toStringItem” label=”toString”>
<mx:Text id=”toStringText” />
</mx:FormItem>
<mx:FormItem id=”nameItem” label=”Name”>
<mx:Text id=”nameText” />
</mx:FormItem>
<mx:FormItem id=”errorIdItem” label=”Error ID”>
<mx:Text id=”errorIdText” />
</mx:FormItem>
</mx:Form>
</mx:VBox>
</mx:Application>
A significant portion of the above code is actually comments. If you remove the explanatory comments, the code is pretty small. Either way, the code is straightforward, especially if you have written Java exception handling code before. Read more…
- Exception Handling with Flex
- Creating a simple image gallery with the Flex TileList control
- Flex Error Handling







