You may be surprised to hear that errors aren’t necessarily a bad thing in scripts. In fact, some features in AppleScript deliberately generate errors in commonly encountered situations, just because catching an error and dealing with it as if it were an error is the simplest way to accomplish a goal.
To catch errors of any kind, AppleScript provides the
try statement and its optional
on error handler. Learn to use them properly with help from this chapter, and errors will become just another tool in your scripting toolkit.
Sometimes the only thing you want to do when your script encounters an error is to make ...