UIPATH-Exception Handling Techniques

UIPATH-Exception Handling Techniques

What is an Exception?

In the world of computers, a programming exception is an event which occurs during the execution of a program that disrupts the normal flow of program’s instructions. Exception handling is the process of responding to the occurrence of exceptions. In other words, exception breaks the normal flow and behaves as per pre- defined error codes or when a special condition is met.

Managing a known and unknown exception plays a very important role in any programming language. It is a pillar of every programming language. Similarly, exception handling performs an extremely key role in UIPATH as well.

UIPATH is a platform where most of the time a robot executes at virtual machines, specifically in the case of the un-attended robot where a user doesn’t have visibility of the processing part. In such scenarios, it becomes very important to deal with the exceptions in the robot very smartly. Otherwise, an unknown exception will abort the process and the user will not be able to get any alert until the user logs in to the orchestrator and checks manually.

With the exception mechanism you can write your code much “cleaner” and have everything “automatically handled” and user friendly.

Few pointers going to cover in UIPATH

1.         How many types of exceptions are there in UIPATH?

2.         What all activities are there in UIPATH to deal with known and unknown scenarios.

3.         Most common error users face in RPA UIPATH.

Different Types of Exceptions in UIPATH: –

There are two types of exceptions we generally found in UiPath..

  1. Business Exception
  2. System Exception

What is Business Exception?

A Business exception describes an error rooted in certain data which the automation project depends on, is incomplete or missing. Such a situation is, for example, a project which read column data from excel sheet provided by the business and that column is missing in the provided file.

We also call business exception as a user defined exception when we apply business rule to our project and if the condition is not satisfied in such situation, we must declare business exception into the code. Retrying the transaction does not yield any chance of solving the issue, and there are other better courses of action, such as notifying the human user of this error.

Another good example of business exception scenario is when you are login into the application and the credentials is changed from the backend in such case bot will try to login and throw a business exception stated Invalid username password.

How to throw Exceptional Business Exception in UIPATH Tool?

Business Rule exception

Wherever you are checking a business rules and conditions are not fulfilling you can use a Throw Activity in the else part and raise a business exception.

Syntax of creating business exception.

Creating business exception

How to capturea Business Exception in UIPATH Tool?

a. Go to the Catch part of try catch.

b. Drop down the Exception Area.

Exception area

c. Browse the Business exception class.

Business exception class

d. Select the exception. After doing these steps under business section area you can mention your action which you want to take it on business exception scenario.

What is System Exception?

System exception can occur due to the unavailability of the item which you declared in your process, and it can occur at any point of time. For example: – A project where a URL need to open in browser and that URL is not responding, in such cases you will encounteran exception which will cover under system exception.

System Exception and Application Exception are similar.Only difference is Application Exception describes an error rooted in a technical issue, such as an application that is not responding. Whereas System Exception is thrown by the common language runtime when errors occur that are nonfatal and recoverable by user programs. You can perform a multiple retry on this exception and if after that it is not recovered you can notify operation team.

How to catch a System Exception?

Below are the steps by using that you can capture the system exception.

Catch a system exception
  • In the Catch section you select the System. Exception Class.
Exception class
  • After selecting the System Exception option, you will this screen in Drop Activity area you can drop you further actions.

Most Common System Exception which you will face in UiPath are below: –

  1. Null reference Exception
  2. Unable to communicate with the browser
  3. Unable to find the element with the selector
  4. System.IO.FileNotFoundException
  5. UiPath.Core.SelectorNotFoundException
  6. System.NullReferenceException
  7. System.ArgumentException 
  8. System.ArgumentNullException

In UIPATH there are different types of Activities available such as: –

  1. Rethrow
  2. Terminate Workflow
  3. Throw
  4. Try Catch

Rethrow – Throws a previously thrown exception from within a Try Catch activity. The error is rethrown retaining the original source of the exception. Rethrow can only be used within a Catch block of a Try Catch activity. In more simple language it is rethrowing the same error to outer try catch block. This most commonly when you are working in framework and with multiple workflow module.

How to Use Rethrow Activity?

Rethrow activity
  • a. Search Rethrow activity from activity panel.
Activity panel
  • Drag and drop rethrow activity into catch part.

Terminate Workflow: –To terminate a Workflow Job at a specific time and throw a specific exception, you can use the Terminate Workflow activity. The Terminate Workflow activity immediately ends the Workflow Job with the specified exception and a Final Severity of “Error”.

Terminate workflow

a. Searches terminate activity in the activity panel.

Terminate activity

b. Drag and drop Terminate Activity.

Exception box

c. Declare the exception in the exception box.

Declare the exception reason

Throw: – To generate a user defined exception we can use Throw Activity. By using Throw activity, you can apply all the business scenario validation in your code. For example: – suppose in project you are receiving excel file with 10 columns. So, you can put a validation if the file is not “.xls” type or number of columns is less than or greater than 10 and create a business exception and send a mail to all the required stack holder so they can correct the format of the file and provide it again.

Search Throw activity

a. Search throw activity into the activity panel.

Property of the throw activity

b. Declare your exception in the property of the Throw activity.

Try Cath Workflow: – Try catch is the main back bone of the code. Wherever it feels like there is possibility of error Try Catch is the activity which can help you to capture your error and handle it nicely so that your process will not interrupt, and other transaction will complete.

Catches a specified exception type in a sequence or activity, and either displays an error notification or dismisses it and continues the execution.

The activity has three main sections:

Try – holds the activity that could throw an exception.

Catches – specifies the exception type and, optionally, holds an activity that informs the user about the found exception.

Finally – holds an activity that should be executed only if no error occurred or if the error was already caught.

There is no limit to how many Catches you can use in a Try Catch activity.
Keep in mind that this activity requires at least two of the three fields to be in use. You cannot run it only with the Try field completed.

Recent try catch
  • Search try catch activity in activity panel and drop in the main workflow.

Or You can right click on sequence or activity which you want to put under try catch condition.

try catch conditions
click on sequence or activity
  • Select you exception type in catch part from the drop-down list and declare your exception actionable.

Leave a Reply

SOAIS - Worksoft Newsletter

To view on your browser, click here
Facebook Twitter LinkedIn
Dear Default Value,

Welcome to SOAIS Newsletter of September 2021!

Continuous Testing with Remote Execution
The speed of innovation continues to increase, driving rapid and relentless change for today’s ever-evolving IT landscapes, creating greater risk as IT and business teams scramble to ensure timely delivery. How can your organization keep pace? Test more, worry less. With Worksoft’s Connective Automation Platform, you can easily build and maintain automated tests, accelerating testing time without losing scope or volume. You can schedule and execute remote, continuous tests to intercept defects sooner and prioritize remediation - without sacrificing your nights and weekends. Explore how continuous test automation and remote execution can empower your organization.

Click here to connect with us to get more information on our services.

Skip Costly Rework with Dynamic Change Resiliency​

Change resiliency is imperative in ever-evolving IT environments. Our patented object action framework streamlines change management by assigning object definitions to your shared assets. The same object may be used in a thousand automation steps, but it can be easily updated by making one simple change to the model definition. The change automatically propagates to every single instance where that object may have been used without a single line of code or manual human involvement. For more change readiness you can also engage our Impact Analysis for SAP to predict how changes in SAP transports will affect your business processes. 

Please click here to watch the video to get a gist.

SOAIS Blog – Nuts and bolts of Certify Database Maintenance​

One of the key thing, which is often missed by the organizations, who have invested in using Worksoft Certify for automating their Business Process Validation initiatives, is implementing a Database Maintenance Plan. While the business and the test automation consultants get excited about the shiny new thing that they have got and start building the regression suite; planning and executing a database maintenance plan for most of the customers gets pushed down the priority list. However, since all the test assets in Certify are stored in a Database, a robust database maintenance plan is very important to maintain smooth operation of Certify with acceptable performance criteria. The customers usually start facing issues once they have built significant number of Certify processes which they have started executing on regular basis. Such executions add a lot of data to the tables storing results data and increase the overall size of the Certify database.

Please click here to read the complete blog.

Worksoft Blog – Process Intelligence: A Multi-Dimensional Approach

The ability to extract process knowledge has become easier through the years. Technology has evolved to the point where we can deploy capabilities that connect at multiple levels to extract different types of process insight. In the past, organizations were forced to spend enormous energy extracting data manually from different applications and databases. Then, they would have to use things like spreadsheets to transform the data and convert it into meaningful information. 

Please click here and read the complete blog.
Unit 9, Level 5, Navigator, ITPL,
Bangalore - 560 066.
Phone: +91 80 40071234
Suite 101, 1979, N Mill St,
Naperville, IL 60563
Phone 1-800-262-2427
Please click here to Unsubscribe / Unsubscribe Preferences

Leave us your info