When use the Exception Handling

Hi All,

I have some questions about exception handling activity, I have confusion to understand this.

What is the use of it and when do we use it?

If my project is dealing with excel files, what exception activity do I need for that?

What is the difference between each activity.

I saw lessons and read about it, but I still find it difficult to understand.

Can someone explain it to me in an easy way?

Thank you

Lets take a example that the Excel is opened and executing some Macro or Doing some basic activity. At that time some Exception occurs in System and closed the Excel .

By the Time some Unexpected errors can be catch using Try catch Block.
Or When you try to Open a file and Its not available in the space.


Thank you for you …

so if i have the for row how i can use the try catch ?

i put the for inside the try right?

and in the catch what i can do ?

because i have multi for row loop and i want use the exception there

@coder ,

So as a Rule - WhatEver you Feel can break during an automation we keep it inside try Catch.

Example : Reading an value from an Excel file.

  1. Exception can be - Excel File is Not available
  2. Value is Not available.

So as a Developer - It depends on how you want to treat the above exceptions .

  1. Excel File Not availalble - Either you stop the Bot or you raise a notification and continue to next part.

Now if we want to send notification and continue - we will keep the Read Excel in Try Block - this means we are telling uipath that this block of code inside may have some Exception.

Now Uipath will ask you - Okay so if I encounter exception - How should i handle it - Then you will go to catch block and specify how to handle it - Select the appropriate exception type in catch – if not sure of type … select system.exception - this will handle all exception.

Then inside the catch- Write Log - Send Email etc … This is send email/ write log and process will continue … to next steps …

Now if you still want to stop automation - you drag Throw activity inside catch - this will again throw the exception and process Breaks

okay - Second Scenario - You are looking for a value inside excel sheet

  1. You did not get the value and you want to intimate someone and continue the proess… same way … put the read cell in try catch and inside catch - SendEmail - Here we have to continue the process … so we will not drag throw …

Hope it make sense


1 Like

Thank you so much Mukeshkala for the explain :grinning:

I understood very well and i will try apply that , I hope it work fine

1 Like

Mukeshkala how i can check this


Value is Not available.


So Readcell will return you the value of the cell you are reading.

For eg : I am reading a cell and expecting a Name and the Name retrieved I am using in some other application , I will use the Readcell activity and store the output is a variable say strName.

So in some instances , if I do not receive a name , the next half of the automation will break and complete process stops.

Here , I will can put this thing in a try catch and in catch section … I send an email saying name was not found for this cell.

Also , alternative way would be to check if strname variable is not null or empty or whitespace - then only we invoke the other part of automation.

Again it depend on the automation nature …


1 Like

Thank you again Mukeshkala now i can do that ,I understood very well , And it become easy for me :grinning:

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.