Skip to content

Function Block

Create an Error Flow

What is an Error Flow?

The drag&bot Studio is able to react to errors occurring in function blocks or programs. For example if a gripper does not close correctly, the function block of the gripper can throw an exception like CLOSE_FAILED. These exceptions can be handled inside the drag&bot Studio by executing different paths inside a program.

In the following diagram you can see how the architecture of drag&bot handles occurring errors.

sequenceDiagram drag&bot Studio ->> Executor: Play Executor -x Function Block: Execute() Function Block --x Executor: Exception Executor ->> drag&bot Studio: Error Thrown drag&bot Studio ->> drag&bot Studio: Stop

Create a simple Error Flow

An exception inside a function block can be thrown like any other exception in Python1. To add a simple error inside your function block add the following line to the python code:

  raise Exception("CLOSE_FAILED")

When the execution does reach the point where the CLOSE_FAILED exception is thrown the program will just stop and a toast in the drag&bot Studio will show a message like Unhandled Error: CLOSE_FAILED.

The video below shows how a function block with an error code can be created which needs to be handled in the drag&bot error flow.


Write your exception in capital letters and separate by underscore like ' MY_SIMPLE_EXCEPTION'.

Handle the Error Flow

When creating a program in drag&bot we can handle a potential error of a function block. We can react to these errors by adding actions to the paths.

  1. Open the builder.
  2. Add the function block to the program.
  3. Select Error Handling on the added function block.
  4. Select + to create a flow.
  5. Select the error handle CLOSE_FAILED.
  6. Add logic to the path.

More Error Handling Functionality

A function block can also react itself to a thrown exception. Therefore the error() method can be used. This method is optional. The error method will be entered when the execute() method does raises an exception. When using the error method we need to raise exception again in order to handle them in drag&bot.


  1. Read more about exception on the Python Documentation page.