Skip to main content
Robot settings

Exception sub-routines

Exception sub-routines

An exception sub-routine is a special sub-routine the robot runs automatically when something goes wrong during the main run. Instead of simply failing and stopping, the robot falls into error handling and runs the actions you defined — sending a notification, logging the problem, or attempting a recovery.


How it works

When the robot hits an unhandled error during a run:

  1. The main flow stops.
  2. The robot calls the configured exception sub-routine automatically.
  3. Once the sub-routine finishes, the robot ends the run with an error status.

It is the same idea as a try/catch block in programming: the main flow is the try, and the exception sub-routine is the catch.


Common uses

  • Sending a WhatsApp message or an email when the robot fails
  • Taking a screenshot at the moment of the error, to make diagnosis easier
  • Logging the error to a spreadsheet or a database
  • Notifying the team responsible before shutting down

Prerequisite

Before configuring this, you need to have created the sub-routine that will handle the error. If you have not, see the sub-routine documentation in the action catalog.


Setting the exception sub-routine

  1. Open the robot's Designer.
  2. Click the gear icon (⚙️) to open the settings.
  3. Find the Exception sub-routine option.
  4. Pick the sub-routine to call when something fails.
  5. Save.

From then on, any unhandled error in the main flow triggers that sub-routine.


Writing a good exception sub-routine

The exception sub-routine is built in the Designer like any other. A few things worth doing:

Identify the robot. Since the sub-routine can be reused across robots, add actions that say which robot the error came from (a parameter holding the robot's name, for instance).

Keep it simple and fast. An exception sub-routine should not be complex. Its job is to notify and log — not to solve the problem.

Avoid actions that can fail too. If the exception sub-routine raises an error of its own, the run ends without the handling you expected. Prefer stable, well-tested actions.

Use parameters for anything dynamic. Email credentials, WhatsApp numbers and other contact details for the notification should come from robot parameters, not from fixed values in the flow.


Turning the exception sub-routine off

To remove the error handling, open the robot's settings, find the Exception sub-routine field and clear the selection.


Next

  • Robot parameters — use secure variables in the exception sub-routine
  • History — review the errors from previous runs
  • Snapshots — restore an earlier version of the robot if you need to