Custom Error Handling (Using Actions)

In addition to the "built-in" error handling provided by the On Error tab, you can use actions to respond to errors in a custom fashion. For example, you might want to try an alternative download site if an HTTP download fails. Or, you might want to present a Yes/No dialog to the user and let them choose whether to close the AutoPlay application.

There are two ways you can trigger a custom error handling routine:

Checking %LastErrorNum%

You can use an IF action to check the built-in variable %LastErrorNum% and determine whether the previous action generated an error.

Using Continue at label

You can use the Continue at label option on an action's On Error tab to jump to your custom error-handling routine when that action generates an error.

Checking %LastErrorNum%

%LastErrorNum% is a built-in variable that gets updated every time an action is performed at run time. If an action is successful, %LastErrorNum% is set to 0. If an action generates an error, %LastErrorNum% is set to a positive integer value that represents the error that occurred.

Each action has its own set of possible error numbers or "return values" that are assigned to %LastErrorNum% when an error occurs. Some actions, like "Page - Hide Object", only have one error number. Others, like "File - Execute", have several.

 SEE ALSO 

 

 

 

?

You can find a complete list of return values for each action in the Command Reference.

You can use %LastErrorNum% in the Condition field of an IF action to test whether the previous action generated an error. Any actions between the IF action and the next corresponding END IF action will only be performed when the preceding action fails.

Your error handler might look something like this:

If you only wanted to handle specific errors, you could set things up like this instead:

Using Continue at label

Another way to trigger a custom error-handling routine is to use the Continue at label option found on an action's On Error tab. Just group your error-handling actions together, preface them with a LABEL, and select that label for the Continue at label option.

You'll probably also want to use GOTO actions and additional labels to skip over your error-handling routines, so they remain isolated from the rest of your actions.

Using the Continue at label option, your error handler might look something like this:

TIP

 

 

 

You can use a variable like %LastActionID% in the Continue at label field to jump to labels that you've named based on the different actions whose errors you want to handle.

Next: Advanced Options