Handle TestStand Run-Time Errors

Updated Dec 6, 2022

Environment

Software

  • TestStand

Operating System

  • Windows

When a run-time error occurs, it is important to consider how it is presented and what options are provided to handle the error. TestStand automatically implements a default built-in error reporting mechanism but also provides you with the tools necessary to implement your own custom error reporting mechanism. This tutorial shows you three different methods to handle errors.

For more information, refer to TestStand Help: Run-Time Errors.
 

Display Run-Time Error Dialog Box

By default, TestStand will display an error dialog when an error occurs. This allows you to interactively handle run-time errors and is useful when building and troubleshooting test sequences.

The Run-Time Error dialog box lists the step and the cause of the error, then prompts you with options for handling the error. The four options provided are the following:
  • Run Cleanup - Generally recommended. Cleanup should normally consist of closing resources that may have been opened during setup of the Sequence File. Leaving these resources open could cause further software or hardware problems down the road.
  • Retry - Retries the step to see if it evaluates properly this time. For example, use this option if you tried to perform a hardware call while the hardware was turned off and have turned the hardware back on. 
  • Ignore - Ignores any errors thrown by the step and continues to execute the sequence.
  • Abort Immediately (no cleanup) - Generally not recommended. Select this option if there are no resources that need to be closed or if you need to immediately exit the program in the case of an emergency.
For further descriptions of these options, refer to TestStand Help: Run-Time Error Dialog Box.


 

Ignore Error, Run Cleanup, or Abort Execution

You can disable the default dialog box behavior by configuring the On Run-Time Error setting. This is generally recommended if the developer will not be executing the test.
  1. In the TestStand Sequence Editor, navigate to Configure >> Station Options.
 
The Station Options dialog box appears.
  1. Navigate to the Execution tab.
  2. Select the desired behavior in the On Run-Time Error drop-down list. For more information on the options, refer to TestStand Help: Station Options Dialog box.
 A screenshot of a cell phone  Description automatically generated
  1. Click OK.

 

Customize Error Handling

If you want to have full control over how errors are presented to the user, use the SequenceFilePostStepRuntimeError engine callback to create a custom sequence that executes whenever an error occurs. The error information is provided to this callback via sequence parameters.

Refer to the Overriding Engine Callbacks - SequenceFilePostStepRuntimeError example for how this can be implemented.

Note: In TestStand 2013 and previous versions, this example is named ErrorHandlerExample.seq and is located in <TestStand Public>\Examples\Callbacks\PostStepRuntimeErrorCallback\.