C H A P T E R 7
5/5/99 ã Apple Computer, Inc.
Many of these errors, such as
"No user interaction allowed"
, are of interest
to scripters. Also of interest to users are errors that have to do with reference
forms, as well as errors such as
"No such object"
. These errors are listed in
“Apple Event Errors” (page 385).
An application scripting error is an error returned by an application when
handling standard AppleScript commands (commands that apply to all
applications). Many of these, such as
"The specified object is a property,
not an element"
, are of interest to users and should be handled. These errors
are listed in “Application Scripting Errors” (page 387). Applications can
deﬁne additional error messages for the AppleScript commands they handle.
An application that deﬁnes such errors should list them in its documentation.
AppleScript errors are errors that occur when AppleScript processes script
statements. Nearly all of these are of interest to scripters. These errors are
listed in “AppleScript Errors” (page 388).
Script errors are error messages sent by a script using the “Error” (page 264)
command. Scripts that deﬁne additional errors will often include
descriptions of the errors in their documentation.
Some “errors” are the result of the normal operation of a
command. For example, the Choose File command returns
error –128, User canceled, if the user presses the Cancel
button in the resulting dialog box. Scripts must routinely
handle such errors to ensure normal operation. For a script
that handles this error, see the Examples section in “Try”
How Errors Are Handled
When an error occurs, AppleScript checks to see if the statement that caused the
error is contained in a Try statement. A Try statement is a two-part compound
statement that contains a series of AppleScript statements, followed by an error
handler to be invoked if any of those statements causes an error. If the
statement that caused the error is included in a Try statement, then AppleScript
passes control to the error handler in the Try statement. After the error handler
completes, control passes to the statement immediately following the end of the