Automation brings a lot of exciting potential for progress, but we always want to do so intelligently.
While building the steps in an automation with a Robotic Process Automation (RPA) tool like UI Path, there is a programming technique we can use to handle for any errors encountered while running our workflow.
The reason we want to handle for errors is because we always want our workflow to produce expected behavior. This helps let us know when something doesn’t go according to plan and more about what went wrong so we can fix it.
The programming concept that provides us with this ability is referred to as a try catch statement.
In this case what happens is we try a step in the automation and if it fails we catch the error or exception to the process.
Let’s see an example.
If our workflow involves us opening a spreadsheet to process the data in the file, we can handle for errors if something doesn’t go according to plan during this step. Perhaps the file has been moved so there is nothing to open. Now, if this happens and we don’t handle for the error it could produce unexpected behavior like a cryptic error message that’s hard to interpret or crash our workflow.
Get our awesome product content delivered daily-ish to your inbox
Instead, the try catch statement gives us the ability to ‘catch’ these potential errors and handle them in a better way. For example, we can configure it to behave in the follow way instead:
- Try to open the spreadsheet
- If you can’t, send me an error message that says ‘Could not open the spreadsheet because the file is missing..’
If your workflow stopped for any reason, wouldn’t it be great to know exactly why with a crystal clear error message like the one above?
That’s the idea. Making it easier to know when something goes wrong and what you need to do to fix it so you can get your workflow back up and running.
PS. Here’s a great resource to learn more about try catch statements.