toString (Error.toString method)

public toString() : String

Returns the string "Error" by default or the value contained in Error.message, if defined.

Availability: ActionScript 1.0; Flash Player 7

Returns

String - A String

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(str1_str:String, str2_str:String):Void {
if (str1_str != str2_str) {
    throw new Error("Strings do not match.");
    }
}
try {
    compareStrings("Dog", "dog");
    // output: Strings do not match.
} catch (e_err:Error) {
    trace(e_err.toString());
}

See also

message (Error.message property), throw statement, try..catch..finally statement