O'Reilly logo

Apple Pro Training Series: AppleScript 1-2-3 by Bill Cheeseman, Sal Soghoian

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required