The ECMAScript core error classes include the Error, EvalError, RangeError, ReferenceError, SyntaxError, TypeError, and URIError classes. Each of these classes are located in the top-level namespace.
|
Class name |
Description |
Notes |
|---|---|---|
|
Error |
The Error class can be used for throwing exceptions, and is the base class for the other exception classes defined in ECMAScript: EvalError, RangeError, ReferenceError, SyntaxError, TypeError, and URIError. |
The Error class serves as the base class for all run-time errors thrown by Flash® Player and Adobe® AIR®, and is the recommended base class for any custom error classes. |
|
EvalError |
An EvalError exception is thrown if any parameters are passed to the Function class's constructor or if user code calls the eval() function. |
In ActionScript 3.0, support for the eval() function has been removed and attempts to use the function cause an error to be thrown. Earlier versions of Flash Player used the eval() function to access variables, properties, objects, or movie clips by name. |
|
RangeError |
A RangeError exception is thrown if a numeric value falls outside of an acceptable range. |
For example, a RangeError would be thrown by the Timer class if a delay was either negative or was not finite. A RangeError could also be thrown if you attempted to add a display object at an invalid depth. |
|
ReferenceError |
A ReferenceError exception is thrown when a reference to an undefined property is attempted on a sealed (nondynamic) object. Versions of the ActionScript compiler before ActionScript 3.0 did not throw an error when access was attempted to a property that was undefined. However, because the new ECMAScript specification specifies that an error should be thrown in this condition, ActionScript 3.0 throws the ReferenceError exception. |
Exceptions for undefined variables point to potential bugs, helping you improve software quality. However, if you are not used to having to initialize your variables, this new ActionScript behavior may require some changes in your coding habits. |
|
SyntaxError |
A SyntaxError exception is thrown when a parsing error occurs in your ActionScript code. For more information, see Section 15.11.6.4 of the ECMAScript (ECMA-262) edition 3 (until edition 4 is available) language specification at www.ecma-international.org/publications/standards/Ecma-262.htm, as well as Section 10.3.1 of the ECMAScript for XML (E4X) specification (ECMA-357 edition 2) at www.ecma-international.org/publications/standards/Ecma-357.htm. |
A SyntaxError can be thrown under the following circumstances:
|
|
TypeError |
The TypeError exception is thrown when the actual type of an operand is different from the expected type. For more information, see Section 15.11.6.5 of the ECMAScript specification at www.ecma-international.org/publications/standards/Ecma-262.htm, as well as Section 10.3 of the E4X specification at www.ecma-international.org/publications/standards/Ecma-357.htm. |
A TypeError can be thrown under the following circumstances:
|
|
URIError |
The URIError exception is thrown when one of the global URI handling functions is used in a way that is incompatible with its definition. For more information, see Section 15.11.6.6 of the ECMAScript specification at www.ecma-international.org/publications/standards/Ecma-262.htm. |
A URIError can be thrown under the following circumstances: An invalid URI is specified for a Flash Player API function that expects a valid URI, such as Socket.connect(). |