If I put invalid Email address(e.g. JohnDoe@g.co) then its show system exception but i want buissnes exception error how can i do

If I put invalid Email address(e.g. JohnDoe@g.co) then its show system exception but i want buissnes exception error how can i do

@Garyy

Try Catch Activity:
Try
– Perform email address validation or processing here –

If email address is invalid, use the following inside the Try block:
Throw Business Rule Exception activity:
  Exception Type: UiPath.Core.BusinessRuleException
  Message: "Invalid email address encountered: JohnDoe@g.co"

Catch BusinessRuleException:
– Handle the business exception here (e.g., log the error, notify users, etc.) –

Catch Exception:
– Handle system exceptions here (optional) –

Surround that activity with try catch
add a business exception saying invalid mail address

1 Like

Hi @Garyy

  1. Before processing the email address, add a custom validation step to check if the email address is valid or not.
  2. If the email address is invalid, throw a BusinessRuleException with a custom error message.

Surround it with try catch
Try
- Validate Email Address (use regular expressions or IsValidEmail activity)
- Send Email (if the email address is valid)
Catch System.Exception ex
- Log Message: "System Exception occurred: " + ex.Message
- Throw Business Exception: “Invalid email address provided.”
End Try

1 Like

This works, thanks!!!

  1. Use a if statement that checks if the mail you have entered is appropriate or not/

  2. If its not appropriate then use throw activity
    image

  3. Go to the properties tab and create a business Exception of the form,
    new BusinessRuleException(“Invalid Email”)

  4. If you want to handle it in the same place, then surround it with try catch and in the above 3 points will be in try scope. In catch scope set exception as BusinessRuleException and place necessary activities like logs etc.

The Sample XAML is Attached :-
Main.xaml (10.5 KB)