Difference between revisions of "Mumps Class 21"
From VistApedia
(Added a glossary link to Action~) |
|||
(2 intermediate revisions by the same user not shown) | |||
Line 10: | Line 10: | ||
GTM>; (except, if you are compiling while executing) | GTM>; (except, if you are compiling while executing) | ||
− | GTM>; 2. Invalid action (happens a lot!!). E.g. Write 1/0 | + | GTM>; 2. Invalid [[action~|Action]] (happens a lot!!). E.g. Write 1/0 |
GTM>; 3. External issue that cuases the process to not be able to continue | GTM>; 3. External issue that cuases the process to not be able to continue | ||
Line 26: | Line 26: | ||
left off | left off | ||
− | GTM>; 3. Record error and stop | + | GTM>; 3. [[Record~|Record]] error and stop |
GTM>; 4. Just end the process | GTM>; 4. Just end the process | ||
Line 239: | Line 239: | ||
06:53, 24 Apr 2011 (PDT)06:53, 24 Apr 2011 (PDT)06:53, 24 Apr 2011 (PDT)06:53, 24 Apr 2011 (PDT)06:53, 24 Apr 2011 (PDT)06:53, 24 Apr 2011 (PDT)06:53, 24 Apr 2011 (PDT)06:53, 24 Apr 2011 (PDT)06:53, 24 Apr 2011 (PDT)06:53, 24 Apr 2011 (PDT)06:53, 24 Apr 2011 (PDT)06:53, 24 Apr 2011 (PDT)06:53, 24 Apr 2011 (PDT)06:53, 24 Apr 2011 (PDT)06:53, 24 Apr 2011 (PDT)~ | 06:53, 24 Apr 2011 (PDT)06:53, 24 Apr 2011 (PDT)06:53, 24 Apr 2011 (PDT)06:53, 24 Apr 2011 (PDT)06:53, 24 Apr 2011 (PDT)06:53, 24 Apr 2011 (PDT)06:53, 24 Apr 2011 (PDT)06:53, 24 Apr 2011 (PDT)06:53, 24 Apr 2011 (PDT)06:53, 24 Apr 2011 (PDT)06:53, 24 Apr 2011 (PDT)06:53, 24 Apr 2011 (PDT)06:53, 24 Apr 2011 (PDT)06:53, 24 Apr 2011 (PDT)06:53, 24 Apr 2011 (PDT)~ | ||
} | } | ||
− | Action (? for help): step OVER// | + | [[Action~|Action]] (? for help): step OVER// |
$STACK is 7 | $STACK is 7 | ||
Line 464: | Line 464: | ||
GTM>D ^KBANERR | GTM>D ^KBANERR | ||
− | %GTM-I-BREAKZBA, Break instruction encountered during ZBREAK action | + | %GTM-I-BREAKZBA, Break instruction encountered during ZBREAK [[action~|Action]] |
At M source location ERR+1^KBANERR | At M source location ERR+1^KBANERR | ||
GTM>ZST INTO | GTM>ZST INTO | ||
DO ERR1 | DO ERR1 | ||
− | %GTM-I-BREAKZST, Break instruction encountered during ZSTEP action | + | %GTM-I-BREAKZST, Break instruction encountered during ZSTEP [[action~|Action]] |
At M source location ERR+2^KBANERR | At M source location ERR+2^KBANERR | ||
Line 491: | Line 491: | ||
GTM>ZSTEP INTO | GTM>ZSTEP INTO | ||
NEW $ETRAP SET $ETRAP="DO TRAP1^KBANERR" | NEW $ETRAP SET $ETRAP="DO TRAP1^KBANERR" | ||
− | %GTM-I-BREAKZST, Break instruction encountered during ZSTEP action | + | %GTM-I-BREAKZST, Break instruction encountered during ZSTEP [[action~|Action]] |
At M source location ERR1+1^KBANERR | At M source location ERR1+1^KBANERR | ||
GTM>ZSTEP INTO | GTM>ZSTEP INTO | ||
WRITE 1/0 | WRITE 1/0 | ||
− | %GTM-I-BREAKZST, Break instruction encountered during ZSTEP action | + | %GTM-I-BREAKZST, Break instruction encountered during ZSTEP [[action~|Action]] |
At M source location ERR1+3^KBANERR | At M source location ERR1+3^KBANERR | ||
Line 517: | Line 517: | ||
GTM>zst into | GTM>zst into | ||
NEW $ETRAP SET $ETRAP="HALT" ; Emergency Error Trap | NEW $ETRAP SET $ETRAP="HALT" ; Emergency Error Trap | ||
− | %GTM-I-BREAKZST, Break instruction encountered during ZSTEP action | + | %GTM-I-BREAKZST, Break instruction encountered during ZSTEP [[action~|Action]] |
At M source location TRAP1+1^KBANERR | At M source location TRAP1+1^KBANERR | ||
Line 535: | Line 535: | ||
GTM>ZST INTO | GTM>ZST INTO | ||
DO DISP | DO DISP | ||
− | %GTM-I-BREAKZST, Break instruction encountered during ZSTEP action | + | %GTM-I-BREAKZST, Break instruction encountered during ZSTEP [[action~|Action]] |
At M source location TRAP1+2^KBANERR | At M source location TRAP1+2^KBANERR | ||
GTM>ZST INTO | GTM>ZST INTO | ||
WRITE "$STACK is ",$STACK,! | WRITE "$STACK is ",$STACK,! | ||
− | %GTM-I-BREAKZST, Break instruction encountered during ZSTEP action | + | %GTM-I-BREAKZST, Break instruction encountered during ZSTEP [[action~|Action]] |
At M source location DISP+1^KBANERR | At M source location DISP+1^KBANERR | ||
Line 546: | Line 546: | ||
$STACK is 4 | $STACK is 4 | ||
WRITE "$ECODE is ",$ECODE,! | WRITE "$ECODE is ",$ECODE,! | ||
− | %GTM-I-BREAKZST, Break instruction encountered during ZSTEP action | + | %GTM-I-BREAKZST, Break instruction encountered during ZSTEP [[action~|Action]] |
At M source location DISP+2^KBANERR | At M source location DISP+2^KBANERR | ||
Line 552: | Line 552: | ||
$ECODE is ,M9,Z150373210, | $ECODE is ,M9,Z150373210, | ||
WRITE "$ETRAP is ",$ETRAP,! | WRITE "$ETRAP is ",$ETRAP,! | ||
− | %GTM-I-BREAKZST, Break instruction encountered during ZSTEP action | + | %GTM-I-BREAKZST, Break instruction encountered during ZSTEP [[action~|Action]] |
At M source location DISP+3^KBANERR | At M source location DISP+3^KBANERR | ||
Line 558: | Line 558: | ||
$ETRAP is HALT | $ETRAP is HALT | ||
QUIT | QUIT | ||
− | %GTM-I-BREAKZST, Break instruction encountered during ZSTEP action | + | %GTM-I-BREAKZST, Break instruction encountered during ZSTEP [[action~|Action]] |
At M source location DISP+4^KBANERR | At M source location DISP+4^KBANERR | ||
GTM>ZST INTO | GTM>ZST INTO | ||
SET $ECODE="" ; Clear Error | SET $ECODE="" ; Clear Error | ||
− | %GTM-I-BREAKZST, Break instruction encountered during ZSTEP action | + | %GTM-I-BREAKZST, Break instruction encountered during ZSTEP [[action~|Action]] |
At M source location TRAP1+3^KBANERR | At M source location TRAP1+3^KBANERR | ||
Line 570: | Line 570: | ||
GTM>ZST INTO | GTM>ZST INTO | ||
GOTO CONT | GOTO CONT | ||
− | %GTM-I-BREAKZST, Break instruction encountered during ZSTEP action | + | %GTM-I-BREAKZST, Break instruction encountered during ZSTEP [[action~|Action]] |
At M source location TRAP1+4^KBANERR | At M source location TRAP1+4^KBANERR | ||
GTM>ZST INTO | GTM>ZST INTO | ||
WRITE "I have been rescued",! | WRITE "I have been rescued",! | ||
− | %GTM-I-BREAKZST, Break instruction encountered during ZSTEP action | + | %GTM-I-BREAKZST, Break instruction encountered during ZSTEP [[action~|Action]] |
At M source location CONT+1^KBANERR | At M source location CONT+1^KBANERR | ||
Line 583: | Line 583: | ||
I have been rescued | I have been rescued | ||
DO DISP | DO DISP | ||
− | %GTM-I-BREAKZST, Break instruction encountered during ZSTEP action | + | %GTM-I-BREAKZST, Break instruction encountered during ZSTEP [[action~|Action]] |
At M source location CONT+2^KBANERR | At M source location CONT+2^KBANERR | ||
GTM>ZST INTO | GTM>ZST INTO | ||
WRITE "$STACK is ",$STACK,! | WRITE "$STACK is ",$STACK,! | ||
− | %GTM-I-BREAKZST, Break instruction encountered during ZSTEP action | + | %GTM-I-BREAKZST, Break instruction encountered during ZSTEP [[action~|Action]] |
At M source location DISP+1^KBANERR | At M source location DISP+1^KBANERR | ||
Line 594: | Line 594: | ||
$STACK is 4 | $STACK is 4 | ||
WRITE "$ECODE is ",$ECODE,! | WRITE "$ECODE is ",$ECODE,! | ||
− | %GTM-I-BREAKZST, Break instruction encountered during ZSTEP action | + | %GTM-I-BREAKZST, Break instruction encountered during ZSTEP [[action~|Action]] |
At M source location DISP+2^KBANERR | At M source location DISP+2^KBANERR | ||
Line 600: | Line 600: | ||
$ECODE is | $ECODE is | ||
WRITE "$ETRAP is ",$ETRAP,! | WRITE "$ETRAP is ",$ETRAP,! | ||
− | %GTM-I-BREAKZST, Break instruction encountered during ZSTEP action | + | %GTM-I-BREAKZST, Break instruction encountered during ZSTEP [[action~|Action]] |
At M source location DISP+3^KBANERR | At M source location DISP+3^KBANERR | ||
Line 606: | Line 606: | ||
$ETRAP is HALT | $ETRAP is HALT | ||
QUIT | QUIT | ||
− | %GTM-I-BREAKZST, Break instruction encountered during ZSTEP action | + | %GTM-I-BREAKZST, Break instruction encountered during ZSTEP [[action~|Action]] |
At M source location DISP+4^KBANERR | At M source location DISP+4^KBANERR | ||
GTM>ZST INTO | GTM>ZST INTO | ||
QUIT | QUIT | ||
− | %GTM-I-BREAKZST, Break instruction encountered during ZSTEP action | + | %GTM-I-BREAKZST, Break instruction encountered during ZSTEP [[action~|Action]] |
At M source location CONT+3^KBANERR | At M source location CONT+3^KBANERR | ||
Line 658: | Line 658: | ||
GTM>ZST INTO | GTM>ZST INTO | ||
DO ERR2 | DO ERR2 | ||
− | %GTM-I-BREAKZST, Break instruction encountered during ZSTEP action | + | %GTM-I-BREAKZST, Break instruction encountered during ZSTEP [[action~|Action]] |
At M source location ERR+3^KBANERR | At M source location ERR+3^KBANERR | ||
Line 665: | Line 665: | ||
GTM>ZST INTO | GTM>ZST INTO | ||
NEW $ETRAP SET $ETRAP="GOTO TRAP1^KBANERR" | NEW $ETRAP SET $ETRAP="GOTO TRAP1^KBANERR" | ||
− | %GTM-I-BREAKZST, Break instruction encountered during ZSTEP action | + | %GTM-I-BREAKZST, Break instruction encountered during ZSTEP [[action~|Action]] |
At M source location ERR2+1^KBANERR | At M source location ERR2+1^KBANERR | ||
GTM>ZST INTO | GTM>ZST INTO | ||
WRITE 1/0 | WRITE 1/0 | ||
− | %GTM-I-BREAKZST, Break instruction encountered during ZSTEP action | + | %GTM-I-BREAKZST, Break instruction encountered during ZSTEP [[action~|Action]] |
At M source location ERR2+3^KBANERR | At M source location ERR2+3^KBANERR | ||
GTM>ZST INTO | GTM>ZST INTO | ||
NEW $ETRAP SET $ETRAP="HALT" ; Emergency Error Trap | NEW $ETRAP SET $ETRAP="HALT" ; Emergency Error Trap | ||
− | %GTM-I-BREAKZST, Break instruction encountered during ZSTEP action | + | %GTM-I-BREAKZST, Break instruction encountered during ZSTEP [[action~|Action]] |
At M source location TRAP1+1^KBANERR | At M source location TRAP1+1^KBANERR | ||
Line 682: | Line 682: | ||
GTM>ZST INTO | GTM>ZST INTO | ||
DO DISP | DO DISP | ||
− | %GTM-I-BREAKZST, Break instruction encountered during ZSTEP action | + | %GTM-I-BREAKZST, Break instruction encountered during ZSTEP [[action~|Action]] |
At M source location TRAP1+2^KBANERR | At M source location TRAP1+2^KBANERR | ||
GTM>ZST INTO | GTM>ZST INTO | ||
WRITE "$STACK is ",$STACK,! | WRITE "$STACK is ",$STACK,! | ||
− | + | |Action]] | |
At M source location DISP+1^KBANERR | At M source location DISP+1^KBANERR | ||
Line 693: | Line 693: | ||
$STACK is 3 | $STACK is 3 | ||
WRITE "$ECODE is ",$ECODE,! | WRITE "$ECODE is ",$ECODE,! | ||
− | %GTM-I-BREAKZST, Break instruction encountered during ZSTEP action | + | %GTM-I-BREAKZST, Break instruction encountered during ZSTEP [[action~|Action]] |
At M source location DISP+2^KBANERR | At M source location DISP+2^KBANERR | ||
Line 699: | Line 699: | ||
$ECODE is ,M9,Z150373210, | $ECODE is ,M9,Z150373210, | ||
WRITE "$ETRAP is ",$ETRAP,! | WRITE "$ETRAP is ",$ETRAP,! | ||
− | %GTM-I-BREAKZST, Break instruction encountered during ZSTEP action | + | %GTM-I-BREAKZST, Break instruction encountered during ZSTEP [[action~|Action]] |
At M source location DISP+3^KBANERR | At M source location DISP+3^KBANERR | ||
Line 705: | Line 705: | ||
$ETRAP is HALT | $ETRAP is HALT | ||
QUIT | QUIT | ||
− | %GTM-I-BREAKZST, Break instruction encountered during ZSTEP action | + | %GTM-I-BREAKZST, Break instruction encountered during ZSTEP [[action~|Action]] |
At M source location DISP+4^KBANERR | At M source location DISP+4^KBANERR | ||
GTM>ZST INTO | GTM>ZST INTO | ||
SET $ECODE="" ; Clear Error | SET $ECODE="" ; Clear Error | ||
− | %GTM-I-BREAKZST, Break instruction encountered during ZSTEP action | + | %GTM-I-BREAKZST, Break instruction encountered during ZSTEP [[action~|Action]] |
At M source location TRAP1+3^KBANERR | At M source location TRAP1+3^KBANERR | ||
GTM>ZST INTO | GTM>ZST INTO | ||
GOTO CONT | GOTO CONT | ||
− | %GTM-I-BREAKZST, Break instruction encountered during ZSTEP action | + | %GTM-I-BREAKZST, Break instruction encountered during ZSTEP [[action~|Action]] |
At M source location TRAP1+4^KBANERR | At M source location TRAP1+4^KBANERR | ||
GTM>ZST INTO | GTM>ZST INTO | ||
WRITE "I have been rescued",! | WRITE "I have been rescued",! | ||
− | %GTM-I-BREAKZST, Break instruction encountered during ZSTEP action | + | %GTM-I-BREAKZST, Break instruction encountered during ZSTEP [[action~|Action]] |
At M source location CONT+1^KBANERR | At M source location CONT+1^KBANERR | ||
Line 726: | Line 726: | ||
I have been rescued | I have been rescued | ||
DO DISP | DO DISP | ||
− | %GTM-I-BREAKZST, Break instruction encountered during ZSTEP action | + | %GTM-I-BREAKZST, Break instruction encountered during ZSTEP [[action~|Action]] |
At M source location CONT+2^KBANERR | At M source location CONT+2^KBANERR | ||
Line 733: | Line 733: | ||
GTM>ZST INTO | GTM>ZST INTO | ||
WRITE "$STACK is ",$STACK,! | WRITE "$STACK is ",$STACK,! | ||
− | %GTM-I-BREAKZST, Break instruction encountered during ZSTEP action | + | %GTM-I-BREAKZST, Break instruction encountered during ZSTEP [[action~|Action]] |
At M source location DISP+1^KBANERR | At M source location DISP+1^KBANERR | ||
Line 739: | Line 739: | ||
$STACK is 3 | $STACK is 3 | ||
WRITE "$ECODE is ",$ECODE,! | WRITE "$ECODE is ",$ECODE,! | ||
− | %GTM-I-BREAKZST, Break instruction encountered during ZSTEP action | + | %GTM-I-BREAKZST, Break instruction encountered during ZSTEP [[action~|Action]] |
At M source location DISP+2^KBANERR | At M source location DISP+2^KBANERR | ||
Line 745: | Line 745: | ||
$ECODE is | $ECODE is | ||
WRITE "$ETRAP is ",$ETRAP,! | WRITE "$ETRAP is ",$ETRAP,! | ||
− | %GTM-I-BREAKZST, Break instruction encountered during ZSTEP action | + | %GTM-I-BREAKZST, Break instruction encountered during ZSTEP [[action~|Action]] |
At M source location DISP+3^KBANERR | At M source location DISP+3^KBANERR | ||
Line 751: | Line 751: | ||
$ETRAP is HALT | $ETRAP is HALT | ||
QUIT | QUIT | ||
− | %GTM-I-BREAKZST, Break instruction encountered during ZSTEP action | + | %GTM-I-BREAKZST, Break instruction encountered during ZSTEP [[action~|Action]] |
At M source location DISP+4^KBANERR | At M source location DISP+4^KBANERR | ||
GTM>ZST INTO | GTM>ZST INTO | ||
QUIT | QUIT | ||
− | %GTM-I-BREAKZST, Break instruction encountered during ZSTEP action | + | %GTM-I-BREAKZST, Break instruction encountered during ZSTEP [[action~|Action]] |
At M source location CONT+3^KBANERR | At M source location CONT+3^KBANERR | ||
Line 763: | Line 763: | ||
GTM>ZST INTO | GTM>ZST INTO | ||
QUIT | QUIT | ||
− | %GTM-I-BREAKZST, Break instruction encountered during ZSTEP action | + | %GTM-I-BREAKZST, Break instruction encountered during ZSTEP [[action~|Action]] |
At M source location ERR+4^KBANERR | At M source location ERR+4^KBANERR | ||
Latest revision as of 22:40, 30 July 2012
sam@sam-desktop:~$ cd pocn-moh/ sam@sam-desktop:~/pocn-moh$ . run_utf8 sam@sam-desktop:~/pocn-moh$ mumps -dir GTM>; WHY DO ERRORS HAPPEN? WHY WHY??? GTM>; 1. Invalid Syntax (doesn't happen; usually caught by compiler) GTM>; (except, if you are compiling while executing) GTM>; 2. Invalid [[action~|Action]] (happens a lot!!). E.g. Write 1/0 GTM>; 3. External issue that cuases the process to not be able to continue GTM>; e.g. Hard disk runs out of space; Transaction is not restartable and s omebody else is playing with the global GTM>; e.g. You run out of lock space GTM>; What does error processing do? GTM>; 1. Try to fix the error to allow normal processing GTM>; 2. Abandon processing for this block, but resume processing where you left off GTM>; 3. [[Record~|Record]] error and stop GTM>; 4. Just end the process GTM>; there is no try/catch in Mumps GTM>; Instead, there is another way of trapping errors, more like VBA GTM>; Mumps uses $ECODE, $ETRAP, and $ESTACK to process errors. GTM>; Example of an Error Trap GTM>zed "ZU" GTM>zed "XWBTCPM" GTM>zed "KBANERR" GTM>zl GTM>zp SIMPLEERR^KBANERR:SIMPLERR+3 %GTM-E-ZPRTLABNOTFND, Label not found in routine GTM>ZED GTM>zp SIMPLEERR^KBANERR:SIMPLEERR+3 SIMPLEERR W 1/0 QUIT GTM>D SIMPLEERR^KBANERR %GTM-E-DIVZERO, Attempt to divide by zero At M source location SIMPLEERR+1^KBANERR GTM>ZSHOW SIMPLEERR+1^KBANERR ($ZTRAP) (Direct mode) +1^GTM$DMOD (Direct mode) GTM>D ^%ZTER GTM>; ^%ZTER logs the error in the VISTA error trap!!! GTM>; To view the error trap in VISTA, run ^XTER, or the menu option that GTM>; does that GTM>D ^XTER In response to the DATE prompt you can enter: 'S' to specify text to be matched in error or routine name 1 error logged on 4/11/2011 1) <(DIVZERO)>SIMPLEERR+1^KBANERR 09:44:34 EHR,EHR 4851 /dev/pts/3 No screened error Enter '^' to quit listing, <RETURN> to continue...: 1 Process ID: 4851 (4851) APR 11, 2011 09:44:34 UCI/VOL: [EHR,EHR] $ZA: 0 Current $IO: /dev/pts/3 Current $ZIO: ^0^12^/dev/pts/3 $ZE= SIMPLEERR+1^KBANERR, Attempt to divide by zero,150373210,-%GTM-E-DIVZERO W 1/0 Which symbol? > ? Enter: ^Q to EXIT '^' to return to the last question Leading character(s) of symbol(s) you wish to examine ^L to obtain a list of all symbols ^P to select a printer and print this error ^M to capture the current error in a mail message ^I to obtain information on key package variables $ to get a display of the $ system variables $ZE= SIMPLEERR+1^KBANERR, Attempt to divide by zero,150373210,-%GTM-E-DIVZERO W 1/0 Which symbol? > ^L $DEVICE= $ECODE=,M9,Z150373210, $ESTACK=3 $ETRAP= $QUIT=0 $STACK=3 $STACK(000)=-dir $STACK(000,"ECODE")= $STACK(000,"PLACE")=+1^GTM$DMOD $STACK(000,"MCODE")= $STACK(001)=DO $STACK(001,"ECODE")=,M9,Z150373210, $STACK(001,"PLACE")=SIMPLEERR+1^KBANERR $STACK(001,"MCODE")= W 1/0 $STACK(002)= $STACK(002,"ECODE")= $STACK(002,"PLACE")= $STACK(002,"MCODE")= $STACK(003)= Enter '^' to quit listing, <RETURN> to continue...: $STACK(003,"ECODE")= $STACK(003,"PLACE")= $STACK(003,"MCODE")= $X $Y=0 12 $ZV=GT.M V5.4-001 Linux x86 %ZT("^XUTL(""XQ"",$J)")= %ZTER11I=EHR,EHR %ZTER11N=1 %ZTER11S= %ZTER11Z=0 %ZTER12A=0 %ZTER12B= %ZTERCNT=32 %ZTERH1=62192 %ZTERROR= %ZTERRT=^%ZTER(1,62192,1,1) %ZTERSUB=%ZTER11S) %ZTERVAP=%ZT( %ZTERVAR=%ZTERVAR %ZTERZE=SIMPLEERR+1^KBANERR, Attempt to divide by zero,150373210,-%GTM-E-DIVZERO $ZE= SIMPLEERR+1^KBANERR, Attempt to divide by zero,150373210,-%GTM-E-DIVZERO W 1/0 Which symbol? > ? Enter: ^Q to EXIT '^' to return to the last question Leading character(s) of symbol(s) you wish to examine ^L to obtain a list of all symbols ^P to select a printer and print this error ^M to capture the current error in a mail message ^I to obtain information on key package variables $ to get a display of the $ system variables $ZE= SIMPLEERR+1^KBANERR, Attempt to divide by zero,150373210,-%GTM-E-DIVZERO W 1/0 Which symbol? > Which error? > Which date? > GTM> GTM>; Let's see how Mumps uses Error Traps GTM>; Mumps executes this code whenever an error happens: GTM>; X $ERAP GTM>; QUIT:$QUIT "" QUIT GTM>ZED GTM>zed GTM>D ^TMGIDE Entering TMG IDE. But first, let's set up an environment... Please type your name: HAB,SMA ?? Please type your name: HAB,SAM HABIEL,SAM M SMH THE WIZARD ================================================== Welcome to the TMG debugging environment ================================================== Options: 1. Start debugger in THIS window. 2. Start debugger CONTROLLER for another Process. 3. Debug, SENDING control to a Controller. === Routine: ^KBANERR (DISP+1^KBANERR) ===================================== === Routine: ^KBANERR (DISP+2^KBANERR) ===================================== === Routine: ^KBANERR (DISP+3^KBANERR) ===================================== === Routine: ^KBANERR (CONT+1^KBANERR) ===================================== === Routine: ^KBANERR (CONT+2^KBANERR) ===================================== +8 ; +9 ERR1 ; Create an error, rescue level === Routine: ^KBANERR (ERR+3^KBANERR) ====================================== KBANERR +1 KBANERR ; Routine to illustrate Error Trapping ; 4/11/11 9:43am +2 ;; +3 ERR +4 NEW $ETRAP SET $ETRAP="D ^%ZTER" ; Default Error Trap +5 DO ERR1 === Routine: ^KBANERR (ERR+4^KBANERR) ====================================== KBANERR +1 KBANERR ; Routine to illustrate Error Trapping ; 4/11/11 9:43am +2 ;; +3 ERR +4 NEW $ETRAP SET $ETRAP="D ^%ZTER" ; Default Error Trap +5 DO ERR1 +6 DO ERR2 >+7 QUIT +8 ; +9 ERR1 ; Create an error, rescue level +10 NEW $ETRAP SET $ETRAP="DO TRAP1^KBANERR" 06:53, 24 Apr 2011 (PDT)06:53, 24 Apr 2011 (PDT)06:53, 24 Apr 2011 (PDT)06:53, 24 Apr 2011 (PDT)06:53, 24 Apr 2011 (PDT)06:53, 24 Apr 2011 (PDT)06:53, 24 Apr 2011 (PDT)06:53, 24 Apr 2011 (PDT)06:53, 24 Apr 2011 (PDT)06:53, 24 Apr 2011 (PDT)06:53, 24 Apr 2011 (PDT)06:53, 24 Apr 2011 (PDT)06:53, 24 Apr 2011 (PDT)06:53, 24 Apr 2011 (PDT)06:53, 24 Apr 2011 (PDT)~ } [[Action~|Action]] (? for help): step OVER// $STACK is 7 $ECODE is ,M9,Z150373210, $ETRAP is HALT I have been rescued $STACK is 7 $ECODE is $ETRAP is HALT (^ to quit) //Leaving TMG debugging environment. Goodbye. GTM>; What we learned: GTM>; Mumps executes the error trap upon an error GTM>; The existence of an error is identified by a non-empty $ECODE GTM>; You can use Goto(s) (normally a bad programming practice) in processin g errors in order to recover from an error. GTM>; You can tell Mumps that there is no longer any errro by setting $ECODE to be empty GTM>zp ^KBANERR KBANERR ; Routine to illustrate Error Trapping ; 4/11/11 9:43am ;; ERR NEW $ETRAP SET $ETRAP="D ^%ZTER" ; Default Error Trap DO ERR1 DO ERR2 QUIT ; ERR1 ; Create an error, rescue level NEW $ETRAP SET $ETRAP="DO TRAP1^KBANERR" ; Dangeous Operation WRITE 1/0 ; End Dangerous Operation CONT WRITE "I have been rescued",! DO DISP QUIT ERR2 ; Create an error, rescue level NEW $ETRAP SET $ETRAP="GOTO TRAP1^KBANERR" ; Dangeous Operation WRITE 1/0 ; End Dangerous Operation WRITE "I have been rescued",! DO DISP QUIT TRAP1 NEW $ETRAP SET $ETRAP="HALT" ; Emergency Error Trap DO DISP SET $ECODE="" ; Clear Error GOTO CONT DISP WRITE "$STACK is ",$STACK,! WRITE "$ECODE is ",$ECODE,! WRITE "$ETRAP is ",$ETRAP,! QUIT SIMPLEERR W 1/0 QUIT GTM>; $ECODE GTM>; $ECODE is set by Mumps when an error happens GTM>; BUT you as a programmer can create your own errors by setting $ECODE GTM>; $ECODE format GTM>; ,M#, GTM>; ,Z#, GTM>; ,U#, GTM>SET $ECODE=",U111," %GTM-E-SETECODE, Non-empty value assigned to $ECODE (user-defined error trap) GTM>SET $ECODE=",Z111," %GTM-E-SETECODE, Non-empty value assigned to $ECODE (user-defined error trap) GTM>SET $ECODE=",M111," %GTM-E-SETECODE, Non-empty value assigned to $ECODE (user-defined error trap) GTM>ZSHOW SIMPLEERR+1^KBANERR ($ZTRAP) (Direct mode) +1^GTM$DMOD (Direct mode) GTM>SET $ECODE=",U111," %GTM-E-SETECODE, Non-empty value assigned to $ECODE (user-defined error trap) GTM>D ^%ZTER GTM>ZGT %GTM-E-INVCMD, Invalid command keyword encountered ZGT ^----- GTM>ZGOTO GTM>D ^XTER In response to the DATE prompt you can enter: 'S' to specify text to be matched in error or routine name 2 errors logged on 4/11/2011 2) <> 10:35:44 EHR,EHR 4851 /dev/pts/3 1) <(DIVZERO)>SIMPLEERR+1^KBANERR 09:44:34 EHR,EHR 4851 /dev/pts/3 No screened error Enter '^' to quit listing, <RETURN> to continue...: 2 Process ID: 4851 (4851) APR 11, 2011 10:35:44 UCI/VOL: [EHR,EHR] $ZA: 0 $ZB: \013 Current $IO: /dev/pts/3 Current $ZIO: ^0^15^/dev/pts/3 $ZE= ,,,- QUIT Last Global Ref: ^%ZOSF("TRMOFF") Which symbol? > ^L $DEVICE= $ECODE=,U111,Z111,M111,U111, $ESTACK=3 $ETRAP= $QUIT=0 $STACK=3 $STACK(000)=-dir $STACK(000,"ECODE")= $STACK(000,"PLACE")=+1^GTM$DMOD $STACK(000,"MCODE")= $STACK(001)=DO $STACK(001,"ECODE")=,U111, $STACK(001,"PLACE")=DISP+4^KBANERR $STACK(001,"MCODE")= QUIT $STACK(002)= $STACK(002,"ECODE")= $STACK(002,"PLACE")= $STACK(002,"MCODE")= $STACK(003)= Enter '^' to quit listing, <RETURN> to continue...: ^ $ZE= ,,,- QUIT Last Global Ref: ^%ZOSF("TRMOFF") Which symbol? > Which error? > Which date? > GTM>; $EC has commas to help you detect the correct error GTM>W $EC GTM>S X=",U111,Z111,M111,U111," GTM>W X["U11" 1 GTM>W X[",U111," 1 GTM>W X[",U111,," 0 GTM>W X[",U111" 1 GTM>W X[",U11," 0 GTM>; $ESTACK GTM>; -> $ESTACK tells you how many levels you are in the stack from the l GTM>; from the last time you newed $ESTACK GTM>; This helps you unwind the stack until you reach your own level GTM>; useful will call a lot of other routines and you don't GTM>; you want to roll back an error that happened in a routine that's GTM>; far above you. GTM>; $QUIT GTM>; $QUIT tells you whether you got called by an extrinsic function or not GTM>; If you call a routine as a function, $quit is 1 GTM>; if you call it with a Do or Xecute, $quit is 0 GTM>; $STACK GTM>; $STACK contains the current stack level GTM>; $STACK(-1) contains the number of levels in the stack GTM>; $STACK(level,"PLACE/MCODE/ECODE") contains information about GTM>; the stack GTM>zed GTM>zbreak ^KBANERR GTM>S $ZSTEP="W $T(@$ZPOS),! B" GTM>ZG GTM>D ^KBANERR %GTM-I-BREAKZBA, Break instruction encountered during ZBREAK [[action~|Action]] At M source location ERR+1^KBANERR GTM>ZST INTO DO ERR1 %GTM-I-BREAKZST, Break instruction encountered during ZSTEP [[action~|Action]] At M source location ERR+2^KBANERR GTM>ZSHOW "S" ERR+2^KBANERR (Direct mode) +1^GTM$DMOD (Direct mode) GTM>W $STACK 1 GTM>W $STACK(-1) 1 GTM>W $STACK(1) DO GTM>W $STACK(1,"MCODE") DO ERR1 GTM>W $STACK(1,"ECODE") GTM>W $STACK(1,"PLACE") ERR+2^KBANERR GTM>ZSTEP INTO NEW $ETRAP SET $ETRAP="DO TRAP1^KBANERR" %GTM-I-BREAKZST, Break instruction encountered during ZSTEP [[action~|Action]] At M source location ERR1+1^KBANERR GTM>ZSTEP INTO WRITE 1/0 %GTM-I-BREAKZST, Break instruction encountered during ZSTEP [[action~|Action]] At M source location ERR1+3^KBANERR GTM>W $STACK(-1) 2 GTM>; i have 2 level GTM>W $STACK 2 GTM>; current level is 2 GTM>W $STACK(2) DO GTM>; level 2 called using a DO command GTM>w $STACK(2,"MCODE") WRITE 1/0 GTM>; current Mumps code GTM>zst into NEW $ETRAP SET $ETRAP="HALT" ; Emergency Error Trap %GTM-I-BREAKZST, Break instruction encountered during ZSTEP [[action~|Action]] At M source location TRAP1+1^KBANERR GTM>zshow TRAP1+1^KBANERR (Direct mode) ERR1+3^KBANERR ($ZTRAP) ERR+2^KBANERR +1^GTM$DMOD (Direct mode) GTM>W $STACK(-1) 3 GTM>W $STACK($STACK(-1)-1,"MCODE") WRITE 1/0 GTM>W $STACK($STACK(-1)-1,"ECODE") ,M9,Z150373210, GTM>ZST INTO DO DISP %GTM-I-BREAKZST, Break instruction encountered during ZSTEP [[action~|Action]] At M source location TRAP1+2^KBANERR GTM>ZST INTO WRITE "$STACK is ",$STACK,! %GTM-I-BREAKZST, Break instruction encountered during ZSTEP [[action~|Action]] At M source location DISP+1^KBANERR GTM>ZST INTO $STACK is 4 WRITE "$ECODE is ",$ECODE,! %GTM-I-BREAKZST, Break instruction encountered during ZSTEP [[action~|Action]] At M source location DISP+2^KBANERR GTM>ZST INTO $ECODE is ,M9,Z150373210, WRITE "$ETRAP is ",$ETRAP,! %GTM-I-BREAKZST, Break instruction encountered during ZSTEP [[action~|Action]] At M source location DISP+3^KBANERR GTM>ZST INTO $ETRAP is HALT QUIT %GTM-I-BREAKZST, Break instruction encountered during ZSTEP [[action~|Action]] At M source location DISP+4^KBANERR GTM>ZST INTO SET $ECODE="" ; Clear Error %GTM-I-BREAKZST, Break instruction encountered during ZSTEP [[action~|Action]] At M source location TRAP1+3^KBANERR GTM>W $STACK 3 GTM>ZST INTO GOTO CONT %GTM-I-BREAKZST, Break instruction encountered during ZSTEP [[action~|Action]] At M source location TRAP1+4^KBANERR GTM>ZST INTO WRITE "I have been rescued",! %GTM-I-BREAKZST, Break instruction encountered during ZSTEP [[action~|Action]] At M source location CONT+1^KBANERR GTM>W $STACK 3 GTM>ZST INTO I have been rescued DO DISP %GTM-I-BREAKZST, Break instruction encountered during ZSTEP [[action~|Action]] At M source location CONT+2^KBANERR GTM>ZST INTO WRITE "$STACK is ",$STACK,! %GTM-I-BREAKZST, Break instruction encountered during ZSTEP [[action~|Action]] At M source location DISP+1^KBANERR GTM>ZST INTO $STACK is 4 WRITE "$ECODE is ",$ECODE,! %GTM-I-BREAKZST, Break instruction encountered during ZSTEP [[action~|Action]] At M source location DISP+2^KBANERR GTM>ZST INTO $ECODE is WRITE "$ETRAP is ",$ETRAP,! %GTM-I-BREAKZST, Break instruction encountered during ZSTEP [[action~|Action]] At M source location DISP+3^KBANERR GTM>ZST INTO $ETRAP is HALT QUIT %GTM-I-BREAKZST, Break instruction encountered during ZSTEP [[action~|Action]] At M source location DISP+4^KBANERR GTM>ZST INTO QUIT %GTM-I-BREAKZST, Break instruction encountered during ZSTEP [[action~|Action]] At M source location CONT+3^KBANERR GTM>W $STACK 3 GTM>ZP ^KBANERR KBANERR ; Routine to illustrate Error Trapping ; 4/11/11 9:43am ;; ERR NEW $ETRAP SET $ETRAP="D ^%ZTER" ; Default Error Trap DO ERR1 DO ERR2 QUIT ; ERR1 ; Create an error, rescue level NEW $ETRAP SET $ETRAP="DO TRAP1^KBANERR" ; Dangeous Operation WRITE 1/0 ; End Dangerous Operation CONT WRITE "I have been rescued",! DO DISP QUIT ERR2 ; Create an error, rescue level NEW $ETRAP SET $ETRAP="GOTO TRAP1^KBANERR" ; Dangeous Operation WRITE 1/0 ; End Dangerous Operation WRITE "I have been rescued",! DO DISP QUIT TRAP1 NEW $ETRAP SET $ETRAP="HALT" ; Emergency Error Trap DO DISP SET $ECODE="" ; Clear Error GOTO CONT DISP WRITE "$STACK is ",$STACK,! WRITE "$ECODE is ",$ECODE,! WRITE "$ETRAP is ",$ETRAP,! QUIT SIMPLEERR W 1/0 QUIT GTM>ZST INTO DO ERR2 %GTM-I-BREAKZST, Break instruction encountered during ZSTEP [[action~|Action]] At M source location ERR+3^KBANERR GTM>W $STACK 1 GTM>ZST INTO NEW $ETRAP SET $ETRAP="GOTO TRAP1^KBANERR" %GTM-I-BREAKZST, Break instruction encountered during ZSTEP [[action~|Action]] At M source location ERR2+1^KBANERR GTM>ZST INTO WRITE 1/0 %GTM-I-BREAKZST, Break instruction encountered during ZSTEP [[action~|Action]] At M source location ERR2+3^KBANERR GTM>ZST INTO NEW $ETRAP SET $ETRAP="HALT" ; Emergency Error Trap %GTM-I-BREAKZST, Break instruction encountered during ZSTEP [[action~|Action]] At M source location TRAP1+1^KBANERR GTM>W $STACK 2 GTM>ZST INTO DO DISP %GTM-I-BREAKZST, Break instruction encountered during ZSTEP [[action~|Action]] At M source location TRAP1+2^KBANERR GTM>ZST INTO WRITE "$STACK is ",$STACK,! |Action]] At M source location DISP+1^KBANERR GTM>ZST INTO $STACK is 3 WRITE "$ECODE is ",$ECODE,! %GTM-I-BREAKZST, Break instruction encountered during ZSTEP [[action~|Action]] At M source location DISP+2^KBANERR GTM>ZST INTO $ECODE is ,M9,Z150373210, WRITE "$ETRAP is ",$ETRAP,! %GTM-I-BREAKZST, Break instruction encountered during ZSTEP [[action~|Action]] At M source location DISP+3^KBANERR GTM>ZST INTO $ETRAP is HALT QUIT %GTM-I-BREAKZST, Break instruction encountered during ZSTEP [[action~|Action]] At M source location DISP+4^KBANERR GTM>ZST INTO SET $ECODE="" ; Clear Error %GTM-I-BREAKZST, Break instruction encountered during ZSTEP [[action~|Action]] At M source location TRAP1+3^KBANERR GTM>ZST INTO GOTO CONT %GTM-I-BREAKZST, Break instruction encountered during ZSTEP [[action~|Action]] At M source location TRAP1+4^KBANERR GTM>ZST INTO WRITE "I have been rescued",! %GTM-I-BREAKZST, Break instruction encountered during ZSTEP [[action~|Action]] At M source location CONT+1^KBANERR GTM>ZST INTO I have been rescued DO DISP %GTM-I-BREAKZST, Break instruction encountered during ZSTEP [[action~|Action]] At M source location CONT+2^KBANERR GTM>W $STACK 2 GTM>ZST INTO WRITE "$STACK is ",$STACK,! %GTM-I-BREAKZST, Break instruction encountered during ZSTEP [[action~|Action]] At M source location DISP+1^KBANERR GTM>ZST INTO $STACK is 3 WRITE "$ECODE is ",$ECODE,! %GTM-I-BREAKZST, Break instruction encountered during ZSTEP [[action~|Action]] At M source location DISP+2^KBANERR GTM>ZST INTO $ECODE is WRITE "$ETRAP is ",$ETRAP,! %GTM-I-BREAKZST, Break instruction encountered during ZSTEP [[action~|Action]] At M source location DISP+3^KBANERR GTM>ZST INTO $ETRAP is HALT QUIT %GTM-I-BREAKZST, Break instruction encountered during ZSTEP [[action~|Action]] At M source location DISP+4^KBANERR GTM>ZST INTO QUIT %GTM-I-BREAKZST, Break instruction encountered during ZSTEP [[action~|Action]] At M source location CONT+3^KBANERR GTM>W $STACK 2 GTM>ZST INTO QUIT %GTM-I-BREAKZST, Break instruction encountered during ZSTEP [[action~|Action]] At M source location ERR+4^KBANERR GTM>W $STACK 1 GTM>ZST INTO GTM>W $STACK 0 GTM>ZED GTM>; if you cause another error in the error trap GTM>; TROLLBACK:$TLEVEL QUIT:$QUIT "" QUIT GTM>; ; correction in the error level GTM>;