Language Guide

CHAPTER 7
Control Statements
Try Statements 211
resultList applies only to commands that return results for multiple objects. If
results for some, but not all, of the objects specified in the command are
available, you can include them in the partial result parameter. If you do
not include a partial result parameter, an empty list ({}) is passed to the
error handler.
expectedType is a class identifier. If a parameter specified in the command was
not of the expected class, and AppleScript was unable to coerce it to the
expected class, then you can include the expected class in the to parameter.
EXAMPLES
The following example shows how to signal and provide a handler for an error.
The CentimeterConversion subroutine signals error number 750 if its
parameter is not a number. The error handler tests the error number, and if it
is equal to 750, returns a string indicating that the parameter must be a real
number or integer.
on CentimeterConversion from x
--make sure the parameter is a real number or an integer
try
if {integer, real} contains class of x then
return x * 2.54
else
error number 750
end if
on error number errorNumber
if errorNumber = 750 then
return "The parameter must be a real number or integer."
else
error errorNumber --unknown error, resignal
end if
end try
end CentimeterConversion
CentimeterConversion from "Cupertino"
--result: "The parameter must be a real number or integer."