I’m struggling with how to use the throw activity i wanna to execute a code that if the is an exception it will hold it and execute the rest of the code that follows
The REFramework is ideal for this. It is built to send the error through the process such that the error is read and the next step is chosen based on the type of error thrown.
However, if your intention is to continue aggregating errors as they occur while moving forward in the code, this will be more challenging, as it will require using a Try Catch for every activity and adding the error to a list or other appendable type in the Catch section. It should be noted that if one activity fails, it’s likely that a lot more will fail only because the first failed (e.g. if the process cannot navigate to a webpage, and the subsequent activities use the webpage, the rest will fail).
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.
- Exception can be - [Excel] File is Not available
- Value is Not available.
So as a Developer - It depends on how you want to treat the above exceptions .
- [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
- 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
thank you for your help this makes sense now