Error handling during loop execution

If we create a loop over Excel sheet (records) rows and for each record we do some actions like copy the field value and enter in another application like Oracle ERP, during the process Exception may appear and the process stops.
Is there a way to skip this row and complete work for the other rows?
Is there a way to record the Exception reason?

Hi @o_islam_elba1a
Do you know what exceptions you are expecting? Do they relate to data problems (like “record not found” in ERP system) or do you refer to exceptions where the bot runs into an error (red status in the recorder panel)?
The first case can be covered with checking for the possible error screen with wait for image action for example and if conditions. Then you can also write what happened into a log.

The second case where the robot would stop in red error can be handled using exception handling action. But in these cases you don’t get the information what was the cause of the error.

1 Like

I mean the second case,
but how can i handle it, during executing the loop particularly what if the bot runs into an error
how can we skip the row and start the loop with the second row?

If I understand you correctly the following is a potential problem:

  • The robot processes a record from excel

  • For some reason the record contains an error that means the ERP cannot accept the input

  • You want to skip that record and then move onto the next row

If the description above is correct (and if it’s not you need to try to describe the problem in similar steps) then you can do some of the following:

  1. Write a “Pre-processing” module that examines your input file and deletes, or marks (ie add in a flag in new column) the record that is faulty. Initially your “faults” will be things like data missing etc, but over time the checklist can grow to “right number of digits in account number” and other more sophisticated issues. This is the slow way but also maybe the best. You could have a code for each error type and write the code to the excel file.

  2. Ignore all input errors and trap the error at ERP level. For example - ERP throws a “Record Not Found” type of message box or something and you use this to terminate processing that record and move to the next one. You would do this using Exception Handling with the main code in ‘try to complete’ and the terminate code in the ‘if an exception occurred’ branch. Exit the loop there and move to the next record.

1 Like

Hi @o_islam_elba1a
I believe what you are looking for is a the exception handling in the loop. It could look like this:
image

This process runs through a list of websites and opens them. The list looks like this:
www.google.com
www.yahoo.com
no web addres
www.amazon.com

It opens google, yahoo, skips the invalid address and opens amazon. Is that what youre looking for in terms of exception handling?
Under the “if an exception ocurred” section you can also log the faulty element into a txt or xls file. Then move on to the next item in the list.

2 Likes