applescript Errors Throwing errors


Example

You can throw your own errors using error. Execution stops at uncaught errors. By default, the error message is "An error has occurred." with error number -2700.

error

error "An error has occurred." number -2700 from «script» to item

You can pass a message with the error which overrides the default message.

error "testing errors"

error "testing errors" number -2700 from «script» to item

Error numbers can also be passed using the parameter number:

error "testing errors" number -1

error "testing errors" number -1 from «script» to item

If you include an error number but no error message, an error message is written for you.

error number -1

error "An error of type -1 has occurred." number -1 from «script» to item

Some error numbers are reserved for certain types of error.

error number -42

error "Too many files open" number -42 from «script» to item