uiPath: How to include try catch for a sequence of statements in loop?

I have a sequence of processes and I want to put a try-catch block in the loop that should catch the error in this statemenet and if the error exists, it should send a mail and then continue to next iteration, otherwise if there’s no error, it should go as it is naturally:


In the above image I want to put try catch block, but the two problems I am facing is:

  1. Not able to add continue block or code snippet.
  2. In the try catch activity zone, I am able to add only one activity, but in catch I want to perform two of them: 1. to send the mail with error alert and 2. to continue the loop with next iteration.
1 Like

Hi @spidey,

You can add more than one activity in the Catch part of a TryCatch with a sequence. If the TryCatch is round the loop activity, you shouldn’t need a continue.
image

1 Like

Wow! Thanks this is exactly what I wanted. Thank you so much

1 Like

Just one quick thing, I want to put mail body as exception message… so what should I use there? Any tips on that?

It depends on your email domain, normally I would use send SMTP mail message. You’ll need email credentials, the email server, and port for sending. This is the Gmail smtp server info:
image

yeah! I mean I want a string variable that contains the entire error message and I will parse it to SMTP body. Any tips for that? Like for example:
ASSIGN
errorMessage = “”

where ERRORMESSAGECODE is a snippet or something that returns a string of the error that was catched in try-catch.

Ah right, that would be variable exception I believe. Specify it in the email body and set the subject to “Process Name - exception” or something similar

I see… thanks again for the help!

No worries! Please mark my first response as the solution :slight_smile:

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