378 Chapter 12: ActionScript Dictionary
Constructor for the Error class
Availability
Flash Player 7.
Usage
new Error([message])
Parameters
message
A string associated with the Error object; this parameter is optional.
Returns
Nothing.
Description
Constructor; creates a new Error object. If message is specified, its value is assigned to the object’s
Error.message property.
Example
In the following example, a function throws an error (with a specified message) if the two strings
that are passed to it are not identical.
function compareStrings(string_1, string_2) {
if(string_1 != string_2) {
throw new Error("Strings do not match.");
}
}
try {
compareStrings("Dog","dog");
} catch (e) {
trace(e.toString());
}
See also
throw
, try..catch..finally
Error.message
Availability
Flash Player 7.
Usage
myError.message
Description
Property; contains the message associated with the Error object. By default, the value of this
property is "
Error". You can specify a message property when you create a new Error object by
passing the error string to the Error constructor function.
See also
throw
, try..catch..finally