How to create an RPA flow to understand Throw and Rethrow
Overview
This tutorial will show you how to create a basic flow which uses the Throw and Rethrow activities, to understand how to work with Exceptions using the Try Catch, Throw and Rethrow.
We’ll create a flow which will allow a bot to read the files and check if they contain any text. The exception scenario here is that no file can be found in the defined directory.
Note: Before working with Throw and Rethrow, it is important to understand the concept of Exception Handling with Try Catch.
Purpose of Throw and Rethrow Activities in RPA
The Throw and Rethrow activities in RPA are essential tools for handling exceptions effectively within automation workflows. The Throw activity allows developers to deliberately trigger an exception when a specific condition is met, helping to enforce error handling mechanisms where necessary. This is particularly useful for validating business rules, ensuring that incorrect or unexpected conditions do not go unnoticed. On the other hand, the Rethrow activity is used within the Catch block of a Try Catch structure to propagate an already caught exception further up the execution chain. This ensures that the exception can be handled at a higher level or logged appropriately before terminating the workflow. Together, these activities provide a structured approach to error handling, making automation more reliable, predictable, and easier to debug.
To learn more about Try Catch, find an example here: How to create an RPA flow using Try-Catch activity.
Components
- RPA
- RPA Management
- RPA Studio
Requirements
- You need to install the latest version of RPA Studio on your machine:
- Download the connection files
- Download RPA Installer from RPA Management. For this tutorial you need to install:
- IDE Studio
- Establish a connection between the RPA Studio and the RPA Management
- You can check the Infor RPA Studio User Guide for the details
- Before we start building the flow, let’s first create a few artifacts needed to set up an RPA flow:
- Create a folder C:\RPA.
- Create an empty text file C:\RPA\Exception_example.txt
Tutorial
Difficulty: Easy
Estimated completion time: 10 Minutes
1. Open RPA Studio
Open RPA Studio on your machine, and sign in, if required.
2. Create a new project
On the Home page click Create New Project and specify the following properties in the pop up window:
- Name: ThrowRethrow
- ProjectLocation: <default>
- Description: Throw and Rethrow
- Language: VB <selected by default>
3. Add a Try Catch block
The Workflow will contain a Sequence, by default. We will start the flow by adding the Try Catch activity block to the Sequence.
You can find the list of activities by clicking Activities in the left-hand side bar or from the View menu in the top bar. Use search to find the activity you want.

4. Define the Try block
We have three sections in the Try Catch block, the Try block, the Catches block and the Finally block.
First, add a Sequence activity to the Try block. We will then setup this Sequence with the Read Text File, Message Box and If activities, in that order. Configure them as follows:
- Read Text File – This activity will reference the text file we created in the pre-requisites section.
- Source Filepath property contains the path of the file
- Let’s create the Argument called FilePath of type string with a default value “C:\RPA\Exception_example.txt“.
- Output property Text will contain the text that was read in the file
- Let’s create the variable called op of type string without default value and add it to the Text box
- Source Filepath property contains the path of the file
- Message Box – We are using this activity to display the text that was read.
- In the Input Text property we will input the op variable that contains the texts.

Before proceeding we have to understand what we are trying to achieve here. The Try Catch block is where our exceptions are handled, so the Throw or Rethrow activities usually go hand in hand.
The Try block contains the activities or sequence that could possibly produce an exception. Here the activities Read Text File and Message Box to display the contents are added. At this stage, an exception would be produced when the Read Text File does not find a file in the referenced path.
The difference between Throw and Rethrow.
- Throw – Simulates an exception. In other words, this allows you to manually produce an exception that you want. It can be used anywhere in your flow where an exception is appropriate.
- Rethrow – Rethrow works in conjunction with the Catch block of a Try Catch activity and it throws an exception that is caught in the Catch block.
5. Define the If block
To simulate an exception, we added an If block to the Try Sequence as the last step. Create a new Boolean variable called exceptionCondition and add it to Condition property. Boolean has 2 potential data values: true and false.
For cases when exceptionCondition is true, add a Throw activity to the Then block. This will trigger the Throw activity, which will throw the exception we intend to raise. Add the following to the Exception property:
new System.IO.IOException(“Input Output Exception”)

For Else add a Message Box activity, for which the input Text property contains: “False – else statement” simply to show that the control is in else.
In this example, the exceptionCondition is set as true so that we always trigger the Then block and Throw an exception.
6. Define the Catch block
If no exception is thrown (ie the file is found), the workflow will not go to the Catch block.
In case the file is not found, then the Catch block is triggered. For our Catch block select System.IO.IOException from the dropdown menu and then you start adding the activities.
First click the IOException and then add a Sequence below it. Otherwise you would be able to add only a single activity within this block. Next just for troubleshooting reason add Message Box to show the expectation and specify the text as followed: “<>”
Under the Message Box, add the Rethrow activity. This will just Throw back the Exception that was caught and terminate the workflow. This exception can be seen in the Error window.
