User Guide
258 Handling Errors
■ Uncaught exceptions are errors thrown with no corresponding logic (like a catch
statement) to respond to them. If your application throws an error, and no appropriate
catch statement or event handler can be found at the current or higher level to handle the
error, the error is considered an uncaught exception.
At run time, Flash Player ignores, by design, uncaught errors and tries to continue playing
if the error doesn’t stop the current SWF file, because users can’t necessarily resolve an
error themselves. The process of ignoring an uncaught error is called “failing silently” and
can complicate debugging applications. The debugger version of Flash Player responds to
an uncaught error by terminating the current script and displaying the uncaught error in
trace statement output or writing the error message to a log file. If the exception object
is an instance of the Error class or one of its subclasses, the
getStackTrace() method is
invoked, and the stack trace information will also be displayed in
trace statement output
or in a log file. For more information about using debugger version of Flash Player, see
“Working with the debugger version of Flash Player” on page 260.
Error handling in ActionScript 3.0
Since many applications can run without building the logic to handle errors, developers are
tempted to postpone building error handling into their applications. However, without error
handling, an application may easily stall or frustrate the user if something doesn’t work as
expected. ActionScript 2.0 has an Error class that allows you to build logic into custom
functions to throw an exception with a specific message. Because error handling is critical for
making a user-friendly application, ActionScript 3.0 includes an expanded architecture for
catching errors.
NOTE
While the ActionScript 3.0 Language Reference documents the exceptions thrown by
many methods, it may not include all possible exceptions for each method. A method
may throw an exception for syntax errors or other problems that are not noted explicitly
in the method description, even when the description does list some of the exceptions a
method throws.