0

我在 OpenScript osing 标准 Java 中构建了自己的错误处理

try{
}

catch () {
}

一切正常,它正确处理异常。但问题是之后脚本不会进入下一次迭代,而只是调用public void finish() throws Exception {}

成功处理异常后,如何使脚本进入下一次迭代?

4

1 回答 1

0

好的,我找到了解决方案。情况是,如果 OpenScript 生成了它自己的一个异常(例如,未找到表单),即使您使用标准 java 语法捕获它,那么这种执行处理似乎是有效的,但脚本不会进入下一次迭代。

因此,解决方案如下:(实际上在文档中有描述):

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 */
}

于 2020-07-13T11:52:02.613 回答