Try catch, throw and rethrow

Throw activity is placed in the try block or the catch block? And can rethrow be used with them at the same time or not ??

Throw activity can be placed in try or catch blocks

while rethrow can be placed in catch block only

But i did not get what you meant by can rethrow be used with them at the same time or not ?

Thanks & Regards,
Nived N

If i used a throw activity inside the try block, doesn’t that mean that my robot will keep throwing an error even when my activity in the try block executes successfully ?

Hi @Amr_Nweery

The throw activity will be used to throw an exception when certain conditions(Business Rules) occur. If you just want to capture system exceptions, then you can put your code under try block without any throw activities. In the catch block for all the System exception you can add the required steps to log or any other steps to be taken when System exception is encountered.

Hope this clarifies

Thanks

@Amr_Nweery

Yes your understanding is correct…throw is to just throw any kind of error…

Rethrow can be used in catch blocks…this rethrows the exception that is caught…typically used when some taks are to be done after catching exception and then again need to throw the same error

Hope this helps

Cheers

2 Likes

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