O'Reilly logo

Professional Adobe® Flex® 3 by Joe Berkovitz, David Hassoun, Andrew Trice, Tom Sugden, Todd Prekaski, Jun Heider, Peter Ent, Joseph Balderson

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 47. Error Handling

This chapter will introduce error handling. We'll cover both handling error events raised by various Flex APIs, such as the RPC services, as well as synchronous inline errors with the ActionScript's runtime exception handling. Compiler errors won't be discussed in this chapter.

Handling errors in Flex is a bit of a tricky proposition because of the asynchronous nature of everything. There is no one main function to place a global error trap catching all unhandled exceptions. Furthermore, many error conditions are triggered by specific events that the developer must implement event handlers in order to be notified of, such as various RPC, file uploading, and drag and drop operations. Failure to implement the handler can sometimes result in silent failures.

Let's get started by looking at working with synchronous error handling with ActionScript's exception-handling functionality.

Exception Handling with Synchronous Code

With Flex, you get the same exception handling provided by ActionScript with the try/catch/finally statements. With this, you'll be able to handle runtime errors in a given method, or bubble errors up the call stack until an appropriate try/catch error handler is found. This will be your tool of choice for managing error conditions and exceptions in synchronous code. However, since Flex is based on an asynchronous timeline event model, there are also plenty of error events raised when failures to open files, call out to services, and so on occur. ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required