因为这个,我一直在敲我的头。在构思 $etrap(错误处理特殊变量)的方式中,您必须小心真正捕获所有错误。我在这方面取得了部分成功。但是我仍然缺少一些东西,因为在用户模式(应用程序模式)下运行时,内部缓存库错误仍然会停止应用程序。
我所做的是:
ProcessX(var)
set sc=$$ProcessXProtected(var)
w !,"after routine call"
quit sc
ProcessXProtected(var)
new $etrap
;This stops Cache from processing the error before this context. Code
; will resume at the line [w !,"after routine call"] above
set $etrap="set $ECODE = """" quit:$quit 0 quit"
set sc=1
set sc=$$ProcessHelper(var)
quit sc
ProcessHelper(var)
new $etrap
; this code tells Cache to keep unwindind error handling context up
; to the previous error handling.
set $etrap="quit:$quit 0 quit"
do AnyStuff^Anyplace(var)
quit 1
AnyStuffFoo(var)
; Call anything, which might in turn call many sub routines
; The important point is that we don't know how many contexts
; will be created from now on. So we must trap all errors, in any
; case.
;Call internal Cache library
quit
毕竟,我可以看到当我从提示符调用程序时它可以工作!但是当我从缓存终端脚本(应用程序模式,我被告知)调用时,它失败并中止程序(错误捕获机制无法按预期工作)。