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.
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:
Launch and create a new process in Process Designer
- Launch Process Designer from the Windows Start menu located under IntelliBuddies Enterprise
Create New Process
Click on New Process and fill in the new process details
Add three Int32 variables and initialize them to 0.
In Activity panel search for Assign
Drag and drop Assign activity to main panel
Compute the division of numbers and assign to result.
Surround the sequence with Try Catch block.
Set the catch block and display the exception in Add Message Box
Save the process
- From the Design tab ribbon, click on Save
Run the process
- From the Design tab ribbon, click on Run
Ensure the process executes and displays an exception message.
Download Example (C#)