source: WorldVistAEHR/trunk/r/KERNEL-XU-A4A7-USC-XG-XLF-XNOA-XPD-XQ-XVIR-ZI-ZOSF-ZOSV-ZT-ZU-%Z-XIP--XQAB--XUC--XUR--ZIN--ZTED/_ZTER.m@ 738

Last change on this file since 738 was 613, checked in by George Lilly, 15 years ago

initial load of WorldVistAEHR

File size: 6.7 KB
RevLine 
[613]1%ZTER ; ISC-SF.SEA/JLI - KERNEL ERROR TRAP TO LOG ERRORS ;3/22/07 11:57
2 ;;8.0;KERNEL;**8,18,32,24,36,63,73,79,86,112,118,162,275,392,455**;JUL 10, 1995;Build 6
3 S ^TMP("$ZE",$J,1)=$$LGR^%ZOSV
4 S ^TMP("$ZE",$J,0)=$$EC^%ZOSV ;$S(^%ZOSF("OS")["GT.M":$ZS,1:$ZE)
5 S ^TMP("$ZE",$J,2)=$ETRAP,$ETRAP="D ERR^%ZTER"
6 S ^TMP("$ZE",$J,3)=$ZA_"~#~"_$ZB
7 I (^TMP("$ZE",$J,0)["-ALLOC,")!(^TMP("$ZE",$J,0)["<STORE>")!(^TMP("$ZE",$J,0)["-MEMORY") D
8 . I '$D(XUALLOC) D
9 . . K (%ZTERLGR,DUZ,DT,DISYS,IO,IOBS,IOF,IOM,ION,IOSL,IOST,IOT,IOS,IOXY,U,XRTL,XQVOL,XQY,XQY0,XQDIC,XQPSM,XQPT,XQAUDIT,XQXFLG,ZTSTOP,ZTQUEUED,ZTREQ,DA,D0,DI,DIC,DIE)
10 . S %ZTER12A="ALLOC"
11 K XUALLOC
12 S %ZTERZE=^TMP("$ZE",$J,0),%ZT("^XUTL(""XQ"",$J)")="" S:'$D(%ZTERLGR) %ZTERLGR=^TMP("$ZE",$J,1)
13 G:$$SCREEN(%ZTERZE,1) EXIT ;Let site screen errors, count don't show
14 ;Get a record.
15 S %ZTERH1=+$H L +^%ZTER(1,%ZTERH1,0):15
16 S %ZTER11N=$P($G(^%ZTER(1,%ZTERH1,0)),"^",2)+1,^%ZTER(1,%ZTERH1,0)=%ZTERH1_"^"_%ZTER11N,^(1,0)="^3.0751^"_%ZTER11N_"^"_%ZTER11N
17 I %ZTER11N=1 S ^%ZTER(1,0)=$P(^%ZTER(1,0),"^",1,2)_"^"_%ZTERH1_"^"_($P(^%ZTER(1,0),"^",4)+1)
18 L -^%ZTER(1,%ZTERH1,0)
19 S %ZTERRT=$NA(^%ZTER(1,%ZTERH1,1,%ZTER11N))
20 S @%ZTERRT@(0)=%ZTER11N,^("ZE")=%ZTERZE S:$D(%ZTERLGR) ^("GR")=%ZTERLGR K %ZTERLGR
21 K %ZTER12A,%ZTER12B
22 ;Save $ZA and $ZB
23 S %ZTER12A=$$ENC($P(^TMP("$ZE",$J,3),"~#~",1)),%ZTER12B=$$ENC($P(^TMP("$ZE",$J,3),"~#~",2))
24 S %ZTER11I=$$UCI()
25 S @%ZTERRT@("H")=$H,^("J")=$J_"^^^"_%ZTER11I_"^"_$J
26 S @%ZTERRT@("I")=$I_"^"_%ZTER12A_"^"_%ZTER12B_"^"_$G(IO("ZIO"))_"^"_$X_"^"_$Y_"^"_$P
27 S %ZTERROR=$$ETXT
28 S %ZTERCNT=0
29 D STACK^%ZTER1 ;Save Special Variables
30 D SAVE("$X $Y",$X_" "_$Y)
31 I ^%ZOSF("OS")["OpenM" D
32 . D SAVE("$ZU(56,2)",$ZU(56,2))
33 . I $ZV["VMS" S $P(@%ZTERRT@("J"),"^",2,3)=$ZF("GETJPI",$J,"PRCNAM")_"^"_$ZF("GETJPI",$J,"USERNAME")
34 D SAVE("$ZV",$ZV)
35 ;End Special Variables
36 I ^%ZOSF("OS")["VAX DSM" K %ZTER11A,%ZTER11B D VXD^%ZTER1 I 1
37 E D
38 . S %ZTERVAR="%" D:$D(%) VAR:$D(%)#2,SUBS:$D(%)>9
39 . F %ZTER11Z=0:0 S %ZTERVAR=$O(@%ZTERVAR) Q:%ZTERVAR="" D VAR:$D(@%ZTERVAR)#2,SUBS:$D(@%ZTERVAR)>9
40 D GLOB
41 S:%ZTERCNT>0 @%ZTERRT@("ZV",0)="^3.0752^"_%ZTERCNT_"^"_%ZTERCNT
42 S:'$D(^%ZTER(1,"B",%ZTERH1)) ^(%ZTERH1,%ZTERH1)=""
43 S ^%ZTER(1,%ZTERH1,1,"B",%ZTER11N,%ZTER11N)=""
44LIN ;Find the line of the error
45 S %ZTERY=$P(%ZTERZE,","),%ZTERX=$P(%ZTERY,"^") S:%ZTERX[">" %ZTERX=$P(%ZTERX,">",2)
46 I %ZTERX'="" D
47 . N X,XCNP,DIF K ^TMP($J,"XTER1")
48 . S X=$P($P(%ZTERY,"^",2),":") Q:X="" X ^%ZOSF("TEST") Q:'$T
49 . S XCNP=0,DIF="^TMP($J,""XTER1""," X ^%ZOSF("LOAD") S %ZTERY=$P(%ZTERX,"+",1)
50 . I %ZTERY'="" F X=0:0 S X=$O(^TMP($J,"XTER1",X)) Q:X'>0 I $P(^(X,0)," ")=%ZTERY S X=X+$P(%ZTERX,"+",2),%ZTZLIN=$G(^TMP($J,"XTER1",X,0)) Q
51 . I %ZTERY="" S X=+$P(%ZTERX,"+",2) Q:X'>0 S %ZTZLIN=$G(^TMP($J,"XTER1",X,0))
52 K ^TMP($J,"XTER1")
53 S:$D(%ZTZLIN) @%ZTERRT@("LINE")=%ZTZLIN K %ZTZLIN
54 I %ZTERROR'="",$D(^%ZTER(2,"B",%ZTERROR)) S %ZTERROR=%ZTERROR_"^"_$P(^%ZTER(2,+$O(^(%ZTERROR,0)),0),"^",2)
55EXIT ;
56 I $G(%ZTER12A)["ALLOC" HALT ;Don't allow job to go on.
57 S $EC="",$ET=$G(^TMP("$ZE",$J,2))
58 K ^TMP("$ZE",$J)
59 K %ZTER11A,%ZTER11B,%ZTERCNT,%ZTER11S,%ZTER11Z,%ZTERVAP,%ZTERVAR,%ZTERSUB,%ZTER11I,%ZTER11D,%ZTER11L,%ZTER11Q,%,%ZTER111,%ZTER112,%ZTER11N
60 K %ZTERRT,%ZTERH1
61 Q
62 ;
63VAR I "%ZTER"'=$E(%ZTERVAR,1,5) D SAVE(%ZTERVAR,@%ZTERVAR) Q
64 S %ZTERCNT=%ZTERCNT+1,@%ZTERRT@("ZV",%ZTERCNT,0)=%ZTERVAR D
65 . I $L(@%ZTERVAR)'>255 S @%ZTERRT@("ZV",%ZTERCNT,"D")=@%ZTERVAR Q
66 . S @%ZTERRT@("ZV",%ZTERCNT,"D")=" **** VALUE IS GREATER THAN 255 CHARACTERS (SEE SUBNODES FOR DATA) *** "
67 . N %ZTER11,%ZTER12
68 . F %ZTER11=1:1 S %ZTER12=$E(@%ZTERVAR,1,245) Q:%ZTER12="" S @%ZTERVAR=$E(@%ZTERVAR,246,$L(@%ZTERVAR)),@%ZTERRT@("ZV",%ZTERCNT,"D",%ZTER11)=%ZTER12
69 . Q
70 Q
71 ;
72SAVE(%n,%v) ;Save name and value into global, use special variables
73 S %ZTERCNT=%ZTERCNT+1,@%ZTERRT@("ZV",%ZTERCNT,0)=%n
74 I $L(%v)<256 S @%ZTERRT@("ZV",%ZTERCNT,"D")=%v Q
75 ;Variable too long for global node
76 S @%ZTERRT@("ZV",%ZTERCNT,"D")=$E(%v,1,255),^("L")=$L(%v)
77 N %i S %v=$E(%v,256,$L(%v))
78 F %i=1:1 Q:'$L(%v) S @%ZTERRT@("ZV",%ZTERCNT,"D",%i)=$E(%v,1,255),%v=$E(%v,256,$L(%v))
79 Q
80 ;
81SUBS S %ZTER11S="" Q:"%ZT("=$E(%ZTERVAR,1,4) Q:",%ZTER11S,%ZTER11L,"[(","_%ZTERVAR_",") S %ZTERVAP=%ZTERVAR_"(",%ZTERSUB="%ZTER11S)"
82 ;
83 S %ZTER11S=%ZTERVAR
84 F S %ZTER11S=$Q(@%ZTER11S) Q:%ZTER11S="" D SAVE(%ZTER11S,@%ZTER11S)
85 Q
86 ;
87GLOB ; save off a list of global subtrees, %ZT is passed in subscripted by name
88 ; %ZTERCNT passed in to count the nodes we traverse
89 ; %ZTERNOD the nodes through which we $QUERY
90 ; %ZTERNAM the names of the global subtrees we're saving
91 ; %ZTEROPN is %ZTERNAM, evaluated, without close paren for $PIECEing
92 N %ZTERNOD,%ZTERNAM,%ZTEROPN
93 S %ZTERNAM="" ; the names of the global subtrees we're saving
94 F S %ZTERNAM=$O(%ZT(%ZTERNAM)) Q:%ZTERNAM="" D
95 . S %ZTERNOD=$NA(@%ZTERNAM) ; fully evaluate all the subscripts (incl. $J)
96 . S %ZTEROPN=$E(%ZTERNOD,1,$L(%ZTERNOD)-1) ; save %ZTERNOD w/o close paren
97 . ;S %ZTERSUB=$QL(%ZTERNOD) ; how many subscripts in the subtree root's name
98 . F S %ZTERNOD=$Q(@%ZTERNOD) Q:%ZTERNOD="" Q:%ZTERNOD'[%ZTEROPN D ; traverse subtree
99 . . S %ZTERCNT=%ZTERCNT+1 ; count each node
100 . . S @%ZTERRT@("ZV",%ZTERCNT,0)=$P(%ZTERNAM,")")_$P(%ZTERNOD,%ZTEROPN,2) ; unevaluated name
101 . . S @%ZTERRT@("ZV",%ZTERCNT,"D")=$G(@%ZTERNOD) ; value of node
102 Q
103 ;
104ETXT() ;Return the Text of the error
105 Q $S(%ZTERZE["%DSM-E":$P($P(%ZTERZE,"%DSM-E-",2),","),1:$P($P(%ZTERZE,"<",2),">"))
106 ;
107ENC(%ZT1) ;Encode a string with control char in \027 format
108 N %ZTI,%ZTB,%ZTC S %ZTB=""
109 F %ZTI=1:1:$L(%ZT1) S %ZTC=$E(%ZT1,%ZTI),%ZTB=%ZTB_$S(%ZTC'?1C:%ZTC,1:"\"_$E($A(%ZTC)+1000,2,4))_","
110 Q $E(%ZTB,1,$L(%ZTB)-1)
111 ;
112UCI() ;Return the UCI
113 N Y I $D(^%ZOSF("UCI")) X ^%ZOSF("UCI")
114 Q $G(Y)
115 ;
116ERR ;Handle an error in %ZTER
117 I $D(%ZTERH1),$D(%ZTER11N) S ^%ZTER(1,%ZTERH1,1,%ZTER11N,"ZE2")="%ZTER error: "_$ECODE
118 ;Should ^TMP("$ZE",$J) be killed here
119 HALT
120 ;
121SCREEN(ERR,%ZT3) ;Screen out certain errors.
122 N %ZTE,%ZTI,%ZTJ S:'$D(ERR) ERR=$$EC^%ZOSV
123 S %ZTE="",%ZTI=0
124 F %ZTJ=2,1 D Q:%ZTI>0
125 . F %ZTI=0:0 S %ZTI=$O(^%ZTER(2,"AC",%ZTJ,%ZTI)) Q:%ZTI="" S %ZTE=$S($G(^%ZTER(2,%ZTI,2))]"":^(2),1:$P(^(0),"^")) Q:ERR[%ZTE
126 . Q
127 ;Next see if we should count the error
128 I %ZTI>0 S %ZTE=$G(^%ZTER(2,%ZTI,0)) D Q $P(%ZTE,"^",3)=2 ;See if we skip the recording of the error.
129 . Q:(%ZTJ=1)&('$G(%ZT3))
130 . I $P(%ZTE,"^",4) L +^%ZTER(2,%ZTI) S ^(3)=$G(^%ZTER(2,%ZTI,3))+1 L -^%ZTER(2,%ZTI)
131 . Q
132 Q 0 ;record error
133 ;
134UNWIND ;Unwind stack for new error trap. Called by app code.
135 S $ECODE="" S $ETRAP="D UNW^%ZTER Q:'$QUIT Q -9" S $ECODE=",U1,"
136UNW Q:$ESTACK>1 S $ECODE="" Q
137 ;
138NEWERR() ;Does this OS support the M95 error trapping
139 Q 1 ;All current M system now support 95 error trapping
140 N % S %=$G(^%ZOSF("OS")) Q:%="" 0
141 I %["MSM",$P($ZV,"Version ",2)'<4.3 Q 1
142 Q 0
143 ;
144ABORT ;Pop the stack all the way.
145 S $ETRAP="Q:$ST>1 S $ECODE="""" Q"
146 Q
147 ;
148POST ;Do the post-init
Note: See TracBrowser for help on using the repository browser.