Handling errors and breaks during loop execution

Created by akaBot Support, Modified on Tue, 6 Aug, 2024 at 9:21 AM by akaBot Support

When executing a loop, if an error occurs and you want to break the loop while still logging the error, you can use a TryCatch activity. Here’s how you can manage the behavior when placing a break activity in the Catches or Finally section, specific to the behavior of the akaBot Platform.

Important Note:

  • Even if you place a break activity in the Catches or Finally section, the loop will only terminate after all the actions within these sections are executed.

Case 1: Break in the Catches Section

Let’s explore the behavior with the following workflow:

【Catches】

Workflow Overview:

The variable item takes values "a", "b", "c", "d", and "e", iterating through a TryCatch block. When item equals "b", an Exception is thrown using the Throw activity, transitioning to the Catches section.

【Catches】

【Finally】

The Catches section is intended to catch the exception and perform necessary logging or other actions before breaking the loop.

Despite the break in the Catches section, all actions specified in the Catches and Finally sections will be executed fully before the loop terminates.


Case 2: Break in the Finally Section

Now, let’s modify the workflow to include a break in the Finally section:

【Catches】

【Finally】

In this case, because the break is placed in the Finally section, the loop will terminate after the first execution of the Finally block. However, as mentioned earlier, all actions within the Finally block will be executed fully before the loop terminates.

Therefore, in the output panel, both "finally - before" and "finally - after" will be logged before the process ends.




Was this article helpful?

That’s Great!

Thank you for your feedback

Sorry! We couldn't be helpful

Thank you for your feedback

Let us know how can we improve this article!

Select at least one of the reasons
CAPTCHA verification is required.

Feedback sent

We appreciate your effort and will try to fix the article