QuickTip: Error Handling Basics

  • 25 August 2020
  • 0 replies

Userlevel 6
Badge +9

In this session, we'll look at the basics of Error Handling in A2019 using the Try, Catch, and Finally Blocks. Remember: Beyond executing the task at hand, your bot's #1 responsibility is to not hard fail leaving a bot runner in a bad state; error handling is the best approach to always being in control of your bots.

Video Recap:

  1. Try
    1. The Try block is for the core code you want to execute.
      1. Should everything run smoothly here, the finally block would run next.
      2. Should things not run as expected, the catch block would run next.
  2. Catch
    1. The Catch block is for code that should handle exceptions. This might include logging to a file, saving off a screenshot of the machine's current state, or even sending an email off to a support team.
    2. After the Catch block runs, the Finally block will execute.
  3. Finally
    1. The Finally block is for code that should execute whether an error occurred in this bot execution or not. This block might include things like writing out to an audit log, closing applications that may have been opened by the bot, or sending off an email to indicate bot run completion along with a status.

Bonus Tip

Did you know you can nest the Try-Catch-Finally blocks? Use a Try block with a Try block inside of it to carefully handle specific commands which may need to be handled with extra sensitivity.

Be sure to stay tuned to developer.automationanywhere.com for more Quick Tips!

0 replies

Be the first to reply!