User Guide
282 Handling Errors
The final method in the ApplicationError class is toString(). This method overrides the
function defined in the Error class so that you can customize the presentation of the error
message. The method returns a string that identifies the specific error number and message
that occurred.
public override function toString():String
{
return "[APPLICATION ERROR #" + id + "] " + message;
}
Defining the FatalError class
The FatalError class extends the custom ApplicationError class and defines three methods: the
FatalError constructor,
getTitle(), and toString(). The first method, the FatalError
constructor, takes a single integer argument,
errorID, and sets the errorβs severity using the
static constant values defined in the ApplicationError class, and gets the specific errorβs error
message by calling the
getMessageText() method in the ApplicationError class. The
FatalError constructor is as follows:
public function FatalError(errorID:int)
{
id = errorID;
severity = ApplicationError.FATAL;
message = getMessageText(errorID);
}
The next method in the FatalError class, getTitle(), overrides the getTitle() method
defined earlier in the ApplicationError class, and appends the text β-- FATALβ in the title to
inform the user that a fatal error has occurred. The
getTitle() method is as follows:
public override function getTitle():String
{
return "Error #" + id + " -- FATAL";
}
The final method in this class, toString(), overrides the toString() method defined in the
ApplicationError class. The
toString() method is
public override function toString():String
{
return "[FATAL ERROR #" + id + "] " + message;
}