Script Editor Icon

Inserting error handlers into your script

Error handlers are routines that are executed whenever an error occurs during the script. You can insert prewritten error handlers into your script using the shortcut menu (also know as a contextual menu).

To insert an error handler into your script:

Step 1

Select the script lines to be enclosed in an error handler. You can also choose to insert an empty error handler into the script text by placing the insertion point on a blank line.

Step 2

Control-click in the selected area.

Step 3

Choose the desired error handler option from the Error Handlers submenu. The selected text will be enclosed within the chosen error handler.

Message and Cancel: Displays the error message in a dialog with a single Cancel button.

Message and OK: Displays the error message in a dialog with a single OK button.

Message and Return: Displays the error message in a dialog with a single OK button, and then returns the error message.

Message if not Cancel: Displays the error message in a dialog with a single Cancel button if the error was not caused by a dialog being canceled (error number -128).

No Message: Adds a basic error handler with no messages or results.

Write Error to Log: Writes the error message to a script log file on the desktop. A subroutine for writing to a file is added at the end of the script if it isn’t already present.

Related Topics

debugging scripts

shortcut menus