User Guide
Example: CustomErrors application 277
Example: CustomErrors application
The CustomErrors application demonstrates techniques for working with custom errors when
building an application. These techniques are:
■ Validating an XML packet
■ Writing a custom error
■ Throwing custom errors
■ Notifying users when an error is thrown
The CustomErrors application files can be found in the Samples/CustomError folder. The
application consists of the following files:
CustomErrors application overview
The CustomErrors.mxml file contains the user interface and some logic for the custom error
application. Once the application’s
creationComplete event is dispatched, the initApp()
method is invoked. This method defines a sample XML packet that will be verified by the
Validator class. The following code shows the
initApp() method:
private function initApp():void
{
employeeXML =
<employee id="12345">
<firstName>John</firstName>
<lastName>Doe</lastName>
<costCenter>12345</costCenter>
<costCenter>67890</costCenter>
File Description
CustomErrors.mxml The main application file consisting of the
MXML user interface.
com/example/programmingas3/errors/
ApplicationError.as
A class that serves as the base error class for
both the FatalError and WarningError classes.
com/example/programmingas3/errors/
FatalError.as
A class that defines a FatalError error that can
be thrown by the application. This class extends
the custom ApplicationError class.
com/example/programmingas3/errors/
Validator.as
A class that defines a single method that
validates a user-supplied employee XML
packet.
com/example/programmingas3/errors/
WarningError.as
A class that defines a WarningError error that
can be thrown by the application. This class
extends the custom ApplicationError class.