Exception scenario

i have a scenario where in a sequence i need to define all exceptions

for example:Unable to find bank report in outlook bot mailbox/shared location

Further Bot Execution : Stop

and if this exception occurs i need to send mail to few people … how do i do this ?

Hello @poojaskyrathore Welcome to the UiPath Community Forum

Sample Solution:

  1. Use Try Catch: Place the activities that might throw an exception inside a Try block.
  2. Catch Specific Exception: In the Catch block, use a condition to check for the specific exception you want to handle. For example, if you want to handle the exception “Unable to find bank report in outlook bot mailbox/shared location,” you can use an If activity with a condition to check if the exception message contains this specific text.
  3. Send Email: Inside the If activity, use the Send Outlook Mail Message or Send SMTP Mail Message activity to send an email to the relevant recipients.

Here’s an example of how the workflow might look:

Try
    {
        // Activities that might throw an exception
    }
Catch (SpecificException ex)
    {
        If (ex.Message.Contains("Unable to find bank report in outlook bot mailbox/shared location"))
            {
                // Send email to relevant recipients
            }
    }

Thanks

if condition has to go in finally block?

@poojaskyrathore No, if condition will be in Catch block only, as I assume there will be multiple exception conditions you will be checking as per posted in initial query. The Catch block will also have Send Email activity after the ElseIF conditions as a separate workflow. And then you need to reThrow the exception.

If you want to put the conditions in Finally, you just need to capture exception string in Catch and then perform the logic. But in this case, your code will ignore the exception and continue processing the next transaction.

Seems like a bit of a ChatGPT answer to suggest doing it with a C# Try Catch Block no? It looks like you ripped it right from a LLM without proper context.

If someone is struggling to do some basic error handling don’t you think its better to suggest tackling it with some low code approaches and using the normal, tried and true, Try Catch activities?

@Jon_Smith Sure, I will try to use sample activity xml along with the description.

Nice, and please remember, if you are relying on LLM to write alot of your posts you are supposed to declare that and not pass it off as your own. :slight_smile: