Skip to main content

Using Try Catch Activity

The Try Catch activity can be used to catch exceptions when an activity or set of activities in the process is executed. The try block inside the activity allows you to define a block of code to be tested for errors while being executed. The catch block enables you to define a block of code to be executed if an error occurs in the try block.

Add Try Catch in following ways:

  • By drag and drop Try Catch activity from activity panel to sequence. Either add before creation or move activity or block of activities for which error is required.

  • In the Main Pane, right-click and choose the option Surround with Try Catch.

  • When a Try Catch block is present in another Try Catch block then it is called the nested try catch block.

Let us understand Try Catch activity with an example process. Here is an example that executes an indeterminate arithmetical calculation divided by 0.

Come, let's create this process in Process Designer:

Step#1

Launch and create a new process in Process Designer

  • Launch Process Designer from the Windows Start menu located under IntelliBuddies Enterprise

Step#2

Create New Process

  • Click on New Process and fill in the new process details

Step#3

  • Add three Int32 variables and initialize them to 0.

Step#4

In Activity panel search for Assign

  • Drag and drop Assign activity to main panel

  • Compute the division of numbers and assign to result.

Step#5

  • Surround the sequence with Try Catch block.

  • Set the catch block and display the exception in Add Message Box

Step#6

Save the process

  • From the Design tab ribbon, click on Save

Step#7

Run the process

  • From the Design tab ribbon, click on Run

Step#8

Ensure the process executes and displays an exception message.

Download Example (C#)