11.07.2015 Views

Caché ObjectScript Reference - InterSystems Documentation

Caché ObjectScript Reference - InterSystems Documentation

Caché ObjectScript Reference - InterSystems Documentation

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

<strong>Caché</strong> <strong>ObjectScript</strong> Special VariablesFor example, a program (named zerrortest) contains the following routine (named ZerrorMain)which attempts to write the contents of FRED, an undefined local variable:ZerrorMainWRITE !, $ZERRORWRITE FREDWRITE !, $ZERRORQUITIn the above example, the first $ZERROR contains a null string (""), because no errors haveoccurred. The second $ZERROR contains *FRED, specifying the name ofthe error and additional information specific to that type of error. In this case, the informationis the name of the undefined local variable FRED.Notes$ZERROR and the Program StackThe portion of the $ZERROR string contains the most recent error message. Thecontents of the entryref portion of the $ZERROR string reflect the stack level of the mostrecent error. The following terminal session attempts to call the nonsense command GOB-BLEDEGOOK, resulting in a error. It also runs ZerrorMain (specified above),resulting in the $ZERROR value . Subsequent $ZERROR values duringthis terminal session reflect this program call, as shown in the following:SAMPLES>gobbledegookSAMPLES>WRITE $ZERRORSAMPLES>DO ^zerrortestSAMPLES>WRITE $ZERRORZerrorMain+2^zerrortest *FREDSAMPLES 2d0>gobbledegookSAMPLES 2d0>WRITE $ZERROR^zerrortestSAMPLES 2d0>QUITSAMPLES>WRITE $ZERROR^zerrortestSAMPLES>gobbledegookSAMPLES>WRITE $ZERROR$ZERROR Actions when $ZTRAP is SetWhen an error occurs and $ZTRAP is set, <strong>Caché</strong> returns the error message in $ZERRORand branches to the error-trap handler specified for $ZTRAP. (For a list of the possible errortexts, refer to System Error Messages in <strong>Caché</strong> Error <strong>Reference</strong>.)470 <strong>Caché</strong> <strong>ObjectScript</strong> <strong>Reference</strong>

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!