Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to really trap all errors with $etrap in Intersystems Caché?
    text
    copied!<p>I've been banging my head a lot because of this. In the way that $etrap (error handling special variable) was conceived you must be careful to really trap all errors. I've been partially successful in doing this. But I'm still missing something, because when run in user mode (application mode) there are <strong>internal Cache library</strong> errors that are still halting the application.</p> <p>What I did was:</p> <pre><code>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 </code></pre> <p>After all this, I can see that when I call the program from a prompt it works! But when I call from Cache Terminal Script (application mode, I was told) it fails and aborts the program (the error trapping mechanism doesn't work as expected).</p> <p>Any lights?</p> <p>Thanks in advance,</p> <p>Luís Fernando</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload