【问题标题】:Problem: OpenScript does not go to the next iteration after handling of Exception问题:处理异常后OpenScript没有进入下一次迭代
【发布时间】:2020-06-28 23:13:33
【问题描述】:

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

try{
}

catch () {
}

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

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

【问题讨论】:

    标签: openscript


    【解决方案1】:

    好的,我找到了解决方案。 情况是,如果 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 */
    }
    
    

    【讨论】:

      猜你喜欢
      • 2021-04-19
      • 1970-01-01
      • 2018-12-08
      • 2016-06-27
      • 1970-01-01
      相关资源
      最近更新 更多