Problem: OpenScript does not go to the next iteration after handling of Exception

蹲街弑〆低调 提交于 2021-01-29 08:40:01

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!