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
Feedback sent
We appreciate your effort and will try to fix the article