问题
I have built my own error handing in OpenScript osing standard Java
try{
}
catch () {
}
Everything works correctly, It handles exception correctly.
But the problem is that afterwards script does not go to the next iteration, but just calls the public void finish() throws Exception {}
How can I make script go to the next iteration after successfully handling of the exception?
回答1:
Ok, I found the solution. The situation is that if OpenScript generates one of its own exceptions (e.g. form is not found), than even if you catch it using standard java syntax, then this execution handling seems to be working, but script does not go to the next iteration.
So, the solution is as follows: (it is actually described in documentation):
beginStep("Trying to execute code, which may go wrong", 0);
// Setting error recovery to warning, so the script will not halt
setErrorRecovery(FormsErrorRecovery.ERR_FORMS_FT_ERROR, ErrorRecoveryAction.Warn);
/*
Some code, which can generate error (e.g. form is not found) needs to go here
*/
// setting error recovery back to Fail, so the script will halt at unexpected error
setErrorRecovery(FormsErrorRecovery.ERR_FORMS_FT_ERROR, ErrorRecoveryAction.Fail);
endStep();
// The hasLastError variable is automatically set to true if there was an error in the previous beginStep() --- endStep() block.
if(!hasLastError()){
/* code goes here to be executed if there was no error */
}
else {
/* code goes here to execute if there was an error */
}
来源:https://stackoverflow.com/questions/62629189/problem-openscript-does-not-go-to-the-next-iteration-after-handling-of-exceptio