我已经构建了我自己的错误处理OpenScript osing标准Java
try{
}
catch () {
}一切都正常工作,它正确地处理异常。但问题是,之后的脚本不会转到下一次迭代,而只是调用public void finish() throws Exception {}
在成功处理异常后,如何让脚本转到下一次迭代?
发布于 2020-07-13 19:52:03
好了,我找到解决方案了。情况是,如果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 */
}https://stackoverflow.com/questions/62629189
复制相似问题