applescript Errors Throwing errors

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Extensions
> Step 2: And Like the video. BONUS: You can also share it!

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



Got any applescript Question?