How to handle errors for a group of commands running in a loop

Say I have created an automation where a group of commands runs and finally, completes an ecommerce process.

The automation script on this website potentially fails at quite a few places, following which an error occurs and the next loop continues.

What I want to do, is log the error and the loop number in a csv file. Typically, this will be possible through something like exception handling, where I can enclose all my code in a parent block, and a catch block will handle the logging of the error case. How do I do this in Kantu?

I went through the commands and statusOK or GotoIf are two options, but looks like I need to check them after every command. Is there a way to check the status for a group of commands?

Luckily not :wink:

!LastCommandOK is reset after each command, but !StatusOK is not:

!StatusOK will be “false” if one command in a list of commands has an error. A successful command after an error does not change the status back to “true”. But if needed, you can use store | true | !statusok to explicitly reset the command back to “true”.

But how do I use !StatusOK. I will still need to check the value of StatusOK after each command in my script. Can the control go to a designated line once the value of StatusOK changes?

You only need to check !StatusOK once after the end your sequence, and then log the error and/or jump to a new line with GotoIf:

  • store | true | !errorignore <== make sure the macro does not stop after an error
  • command 1
  • command 2
  • command 3
  • If | {!statusOK} == false } <== logs error
    echo | there was an error in loop ${!loop}
    end
  • GotoIf | {!statusOK} == false } | designated line <== Jumps to line on error

So if an error happens with command 1 or command 2 or command 3 it will be catched and handled.

For external error handling options see the command line options.

thank you for your hard working, the ui vision rpa is “god tool!”

could you please design try/except keywords like python! !statusOK feels weird.

You have to test statusOK for each command1,2,3
The current example is just testing statusOK for command3

hello, I want to ask what is the real type (command, target, value) in command 1, command 2, command 3 on the example?

and about to gotoif, what is the real type of designated line?