Error Handling

Sometimes things don’t go as planned during an experiment - a parameter might be wrong, or the user may want to stop the experiment early. The blocks in this section allow you to react to these situations in a controlled way, so your experiment doesn’t just stop unexpectedly without any response.

If you are new to error handling, take a look at the Error Handling Examples to see these blocks in action with step-by-step explanations.

Do On Manual Stop

../../../_images/do_on_manual_stop.png

This block lets you define what should happen when you manually stop the experiment using the stop button in Zahner Lab.

For example, in the image above, the user LED is set to red whenever the experiment is stopped by the user.

Do On Error

../../../_images/do_on_error.png

This block acts as a safety net for your experiment. It lets you define what should happen if something goes wrong - instead of the experiment just stopping with an error.

The block has three sections: do, on error, and finally.

do

This is where you place your normal experiment blocks - the steps that should run under normal conditions.

If everything works correctly, only this section is executed. But if a problem occurs at any point, the experiment immediately stops running the remaining blocks in do and jumps to the on error section.

on error

This section only runs if a problem occurred in the do section. Here you can define how to respond - for example, by turning on a warning LED, showing a message, or safely shutting down a device.

Without this block, your experiment would simply stop when an error occurs. With it, you stay in control of what happens next.

finally

This section is optional - you can enable it using the checkbox on the block. When enabled, it always runs at the end, no matter whether an error occurred or not.

This is useful for cleanup actions, such as turning off outputs or resetting a device to a safe state.

Error Type and Message

When an error occurs, two pieces of information are available to help you understand what went wrong:

Error Type

There are two possible error types:

  • "SCRIPT" - Something in your experiment setup is wrong, such as an invalid value or an unexpected condition.

  • "DEVICE" - The IM7 reported a problem, for example because a measurement parameter is out of range.

You can read the error type string using this block:

../../../_images/error_type.png

Error Message

The error message provides additional details about what exactly went wrong. You can access it with this block:

../../../_images/error_message.png

Exit Experiment

../../../_images/exit_experiment.png

This block stops the experiment immediately. You can place it anywhere in your experiment, but it is especially useful inside the on error section - for example, when an error is so severe that the experiment should not continue.

See also

Error Handling Examples for practical step-by-step examples showing how all of these blocks work together.