Language Guide

CHAPTER 7
Control Statements
Try Statements 205
which is an integer that identifies the error, an error expression, which is an
expression, usually a string, that describes the error, and other information.
To handle error messages, scripts can include error handlers. Error handlers
are contained in compound statements, called Try statements, that define the
scope of the error handlers they contain. If an error message occurs and there
is no handler for it, script execution stops.
Kinds of Errors 7
Every script error falls into one of the following categories:
Operating System errors are errors that occur when AppleScript or an
application requests services from the Operating System. They are rare, and,
more importantly, there’s usually nothing you can do about them in a script.
A few, such as "File <name> wasn't found" and "Application
isn't running", make sense for scripts to handle. These errors are listed
in Appendix C, “Error Messages.”
Apple event errors are Operating System errors that occur when the
underlying message system for AppleScript—known as Apple events—fails.
Many of these errors, such as "No user interaction allowed", are
of interest to users. Also of interest to users are errors that have to do with
reference forms, as well as errors like "No such object". These errors are
listed in Appendix C, “Error Messages.”
Apple Event Registry errors are errors returned by applications 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 Appendix C, “Error Messages.”
AppleScript errors are errors that occur when AppleScript processes script
statements. Nearly all of these are of interest to users. These errors are listed
in Appendix C, “Error Messages.”
Application errors are any additional errors returned by applications.
Applications can define any number of additional error messages for
the AppleScript commands they handle. These errors are listed in the
documentation for applications that define them.