Articles → UIPATH → Try Catch Activity In Uipath

Try Catch Activity In Uipath






Purpose






  1. Try → Here, an exception-prone code will come
  2. Catch → Here, the action takes place (display or ignore exception) when an exception occurs
  3. Finally → This is the section that gets executed whether the exception occurs or does not occur

Example




  1. Drag and drop the "Try Catch" activity
  2. Inside the try block, drag, and drop the "Open Application" activity
  3. Inside the "Open Application" activity, open the Notepad application
  4. Picture showing the open application activity inside the try block
    Click to Enlarge

  5. To make it an error-prone activity, go to the selector of "Open Application" and make the application name "notepad1.exe" instead of "notepad.exe"
  6. Picture showing the selector editor with the application name changes from notepad to notepad1
    Click to Enlarge

  7. In the catch block, select the exception type
  8. Picture showing the Catch block to select the type of exception
    Click to Enlarge

  9. Drag and drop the "Message Box" inside the catches
  10. Picture showing the message box inside the catch block
    Click to Enlarge

  11. In the finally section, drag and drop the "Message Box" activity
  12. Picture showing the message box inside the finally block
    Click to Enlarge

  13. Save and run the bot

Output


Picture showing the execution of catch block when an exception occurs and the finally block
Click to Enlarge


Posted By  -  Karan Gupta
 
Posted On  -  Friday, February 19, 2021

Query/Feedback


Your Email Id
 
Subject
 
Query/FeedbackCharacters remaining 250