そのせいで頭をよく打った。$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
このすべての後、プロンプトからプログラムを呼び出すと、プログラムが機能することがわかります! しかし、キャッシュ ターミナル スクリプト (アプリケーション モード) から呼び出すと、失敗してプログラムが中止されます (エラー トラップ メカニズムが期待どおりに機能しません)。