Lesson 12. Error Handlers

The try Statement

The on error Handler

Throwing Errors

A Practical Example

What’s Next?

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.

The try Statement

Sometimes the only thing you want to do when your script encounters an error is to make ...

Get Apple Pro Training Series: AppleScript 1-2-3 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.