Home   Package List   Routine Alphabetical List   Global Alphabetical List   FileMan Files List   FileMan Sub-Files List   Package Component Lists   Package-Namespace Mapping  
Routine: ZTER

ZTER.m

Go to the documentation of this file.
  1. %ZTER ; ISC-SF.SEA/JLI - KERNEL ERROR TRAP TO LOG ERRORS ;09/06/2017
  1. ;;8.0;KERNEL;**8,18,32,24,36,63,73,79,86,112,118,162,275,392,455,431,582,685**;JUL 10, 1995;Build 2
  1. ;Per VA Directive 6402, this routine should not be modified.
  1. S ^TMP("$ZE",$J,1)=$$LGR^%ZOSV
  1. S ^TMP("$ZE",$J,0)=$$EC^%ZOSV
  1. S ^TMP("$ZE",$J,2)=$ETRAP,$ETRAP="D ERR^%ZTER"
  1. S ^TMP("$ZE",$J,3)=$ZA_"~#~"_$ZB
  1. I (^TMP("$ZE",$J,0)["-ALLOC,")!(^TMP("$ZE",$J,0)["<STORE>")!(^TMP("$ZE",$J,0)["-MEMORY") D
  1. . I '$D(XUALLOC) D
  1. . . 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)
  1. . S %ZTER13A="ALLOC"
  1. Z1 K XUALLOC
  1. S %ZTERZE=^TMP("$ZE",$J,0),%ZT("^XUTL(""XQ"",$J)")="" S:'$D(%ZTERLGR) %ZTERLGR=^TMP("$ZE",$J,1)
  1. G:$$SCREEN(%ZTERZE,1) EXIT ;Let site screen errors, count don't show
  1. ;Get a record.
  1. S %ZTERH1=+$H L +^%ZTER(1,%ZTERH1,0):15
  1. S %ZTER11N=$P($G(^%ZTER(1,%ZTERH1,1,0)),"^",3)
  1. ;S %ZTER11N=$P($G(^%ZTER(1,%ZTERH1,0)),"^",2)+1,^%ZTER(1,%ZTERH1,0)=%ZTERH1_"^"_%ZTER11N,^(1,0)="^3.0751^"_%ZTER11N_"^"_%ZTER11N
  1. Z2 S %ZTER11N=%ZTER11N+1 G:$D(^%ZTER(1,%ZTERH1,1,%ZTER11N,0)) Z2
  1. S %ZTER11C=$P($G(^%ZTER(1,%ZTERH1,0)),"^",2)+1
  1. S ^%ZTER(1,%ZTERH1,0)=%ZTERH1_"^"_%ZTER11C,^%ZTER(1,%ZTERH1,1,0)="^3.0751^"_%ZTER11N_"^"_%ZTER11C
  1. I %ZTER11N=1 S ^%ZTER(1,0)="ERROR LOG^3.075^"_%ZTERH1_"^"_($P(^%ZTER(1,0),"^",4)+1)
  1. S %ZTERRT=$NA(^%ZTER(1,%ZTERH1,1,%ZTER11N))
  1. S @%ZTERRT@(0)=%ZTER11N_"^"_$G(%ZTERAPP),^("ZE")=%ZTERZE S:$D(%ZTERLGR) ^("GR")=%ZTERLGR K %ZTERLGR ;p431
  1. L -^%ZTER(1,%ZTERH1,0)
  1. K %ZTER12A,%ZTER12B,%ZTER11C
  1. ;Save $ZA and $ZB
  1. S %ZTER12A=$$ENC($P(^TMP("$ZE",$J,3),"~#~",1)),%ZTER12B=$$ENC($P(^TMP("$ZE",$J,3),"~#~",2))
  1. S %ZTER11I=$$UCI()
  1. S @%ZTERRT@("H")=$H,^("J")=$J_"^^^"_%ZTER11I_"^"_$J
  1. S @%ZTERRT@("I")=$I_"^"_%ZTER12A_"^"_%ZTER12B_"^"_$G(IO("ZIO"))_"^"_$X_"^"_$Y_"^"_$P
  1. S %ZTERROR=$$ETXT
  1. S %ZTERCNT=0
  1. D STACK^%ZTER1 ;Save Special Variables
  1. D SAVE("$X $Y",$X_" "_$Y)
  1. I ^%ZOSF("OS")["OpenM" D
  1. . D SAVE("$ZU(56,2)",$ZU(56,2))
  1. . I $ZV["VMS" S $P(@%ZTERRT@("J"),"^",2,3)=$ZF("GETJPI",$J,"PRCNAM")_"^"_$ZF("GETJPI",$J,"USERNAME")
  1. D SAVE("$ZV",$ZV)
  1. ;End Special Variables
  1. I ^%ZOSF("OS")["VAX DSM" K %ZTER11A,%ZTER11B D VXD^%ZTER1 I 1
  1. E D
  1. . S %ZTERVAR="%"
  1. . F D VAR:$D(@%ZTERVAR)#2,SUBS:$D(@%ZTERVAR)>9 S %ZTERVAR=$O(@%ZTERVAR) Q:%ZTERVAR=""
  1. D GLOB
  1. S:%ZTERCNT>0 @%ZTERRT@("ZV",0)="^3.0752^"_%ZTERCNT_"^"_%ZTERCNT
  1. S:'$D(^%ZTER(1,"B",%ZTERH1)) ^(%ZTERH1,%ZTERH1)=""
  1. S ^%ZTER(1,%ZTERH1,1,"B",%ZTER11N,%ZTER11N)=""
  1. LIN ;Find the line of the error
  1. S %ZTERY=$P(%ZTERZE,","),%ZTERX=$P(%ZTERY,"^") S:%ZTERX[">" %ZTERX=$P(%ZTERX,">",2)
  1. I %ZTERX'="" D
  1. . N X,XCNP,DIF K ^TMP($J,"XTER1")
  1. . S X=$P($P(%ZTERY,"^",2),":") Q:X="" X ^%ZOSF("TEST") Q:'$T
  1. . S XCNP=0,DIF="^TMP($J,""XTER1""," X ^%ZOSF("LOAD") S %ZTERY=$P(%ZTERX,"+",1)
  1. . 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
  1. . I %ZTERY="" S X=+$P(%ZTERX,"+",2) Q:X'>0 S %ZTZLIN=$G(^TMP($J,"XTER1",X,0))
  1. K ^TMP($J,"XTER1")
  1. S:$D(%ZTZLIN) @%ZTERRT@("LINE")=%ZTZLIN K %ZTZLIN
  1. I %ZTERROR'="",$D(^%ZTER(2,"B",%ZTERROR)) S %ZTERROR=%ZTERROR_"^"_$P(^%ZTER(2,+$O(^(%ZTERROR,0)),0),"^",2)
  1. EXIT ;
  1. D ECNT ;Update the Error Count in the Summary
  1. I $G(%ZTER13A)["ALLOC" HALT ;Don't allow job to go on.
  1. S $EC="",$ET=$G(^TMP("$ZE",$J,2))
  1. K ^TMP("$ZE",$J)
  1. K %ZTER11A,%ZTER11B,%ZTER11D,%ZTER11H,%ZTER11I,%ZTER11L,%ZTER11N,%ZTER11Q,%ZTER11S,%ZTER11Z,%ZTER111,%ZTER112
  1. K %ZTER12A,%ZTER12B,%ZTER13A,%ZTERVAP,%ZTERVAR,%ZTERSUB,%ZTERROR,%ZTERZE
  1. K %ZTERRT,%ZTERH1,%ZTERCNT,%ZTERX,%ZTERY,%ZT
  1. H 1 ;Slow down process
  1. Q
  1. ;
  1. VAR I "%ZTER"'=$E(%ZTERVAR,1,5) D SAVE(%ZTERVAR,@%ZTERVAR) Q
  1. Q
  1. ;
  1. SAVE(%ZTERN,%ZTERV) ;Save name and value into global, use special variables
  1. S %ZTERCNT=%ZTERCNT+1,@%ZTERRT@("ZV",%ZTERCNT,0)=%ZTERN
  1. I $L(%ZTERV)<256 S @%ZTERRT@("ZV",%ZTERCNT,"D")=%ZTERV Q
  1. ;Variable too long for global node
  1. S @%ZTERRT@("ZV",%ZTERCNT,"D")=$E(%ZTERV,1,255),^("L")=$L(%ZTERV)
  1. N %ZTERI
  1. F %ZTERI=1:1 S %ZTERV=$E(%ZTERV,256,$L(%ZTERV)) Q:'$L(%ZTERV) S @%ZTERRT@("ZV",%ZTERCNT,"D",%ZTERI)=$E(%ZTERV,1,255)
  1. Q
  1. ;
  1. SUBS ;Save sub-nodes
  1. S %ZTER11S="" Q:"%ZT("=$E(%ZTERVAR,1,4) Q:",%ZTER11S,%ZTER11L,"[(","_%ZTERVAR_",")
  1. S %ZTERVAP=%ZTERVAR_"(",%ZTERSUB="%ZTER11S)"
  1. S %ZTER11S=%ZTERVAR
  1. F S %ZTER11S=$Q(@%ZTER11S) Q:%ZTER11S="" D SAVE(%ZTER11S,@%ZTER11S)
  1. Q
  1. ;
  1. GLOB ; save off a list of global subtrees, %ZT is passed in subscripted by name
  1. ; %ZTERCNT passed in to count the nodes we traverse
  1. ; %ZTERNOD the nodes through which we $QUERY
  1. ; %ZTERNAM the names of the global subtrees we're saving
  1. ; %ZTEROPN is %ZTERNAM, evaluated, without close paren for $PIECEing
  1. N %ZTERNOD,%ZTERNAM,%ZTEROPN
  1. S %ZTERNAM="" ; the names of the global subtrees we're saving
  1. F S %ZTERNAM=$O(%ZT(%ZTERNAM)) Q:%ZTERNAM="" D
  1. . S %ZTERNOD=$NA(@%ZTERNAM) ; fully evaluate all the subscripts (incl. $J)
  1. . S %ZTEROPN=$E(%ZTERNOD,1,$L(%ZTERNOD)-1) ; save %ZTERNOD w/o close paren
  1. . ;S %ZTERSUB=$QL(%ZTERNOD) ; how many subscripts in the subtree root's name
  1. . F S %ZTERNOD=$Q(@%ZTERNOD) Q:%ZTERNOD="" Q:%ZTERNOD'[%ZTEROPN D ; traverse subtree
  1. . . S %ZTERCNT=%ZTERCNT+1 ; count each node
  1. . . S @%ZTERRT@("ZV",%ZTERCNT,0)=$P(%ZTERNAM,")")_$P(%ZTERNOD,%ZTEROPN,2) ; unevaluated name
  1. . . S @%ZTERRT@("ZV",%ZTERCNT,"D")=$G(@%ZTERNOD) ; value of node
  1. Q
  1. ;
  1. ETXT() ;Return the Text of the error
  1. Q $S(%ZTERZE["%DSM-E":$P($P(%ZTERZE,"%DSM-E-",2),","),1:$P($P(%ZTERZE,"<",2),">"))
  1. ;
  1. ENC(%ZT1) ;Encode a string with control char in \027 format
  1. N %ZTI,%ZTB,%ZTC S %ZTB=""
  1. F %ZTI=1:1:$L(%ZT1) S %ZTC=$E(%ZT1,%ZTI),%ZTB=%ZTB_$S(%ZTC'?1C:%ZTC,1:"\"_$E($A(%ZTC)+1000,2,4))_","
  1. Q $E(%ZTB,1,$L(%ZTB)-1)
  1. ;
  1. UCI() ;Return the UCI, Changed to Box:Volume p431
  1. N Y S Y=""
  1. D GETENV^%ZOSV S Y=$P(Y,"^",4)
  1. Q Y
  1. ;
  1. APPERROR(%ZTERNM) ;Caller gives name to Error. p431
  1. S ^TMP("$ZE",$J,1)=$$LGR^%ZOSV
  1. S ^TMP("$ZE",$J,0)=%ZTERNM
  1. S ^TMP("$ZE",$J,2)=$ETRAP,$ETRAP="D ERR^%ZTER"
  1. S ^TMP("$ZE",$J,3)=$ZA_"~#~"_$ZB
  1. S %ZTERAPP=1
  1. G Z1
  1. ;
  1. ERR ;Handle an error in %ZTER
  1. I $D(%ZTERH1),$D(%ZTER11N) S ^%ZTER(1,%ZTERH1,1,%ZTER11N,"ZE2")="%ZTER error: "_$ECODE
  1. ;Should ^TMP("$ZE",$J) be killed here
  1. HALT
  1. ;
  1. ECNT ;Add to the error count
  1. S %ZTER11A=$$FMT(%ZTERZE),%ZTER11N=0
  1. I $L(%ZTER11A) L +^%ZTER(3.077,0):15 D L -^%ZTER(3.077,0)
  1. . S %ZTER11N=$O(^%ZTER(3.077,"B",$E(%ZTER11A,1,30),0))
  1. . I '%ZTER11N F Q:%ZTER11N D
  1. . . S %ZTER11N=$P($G(^%ZTER(3.077,0)),"^",3)+1,$P(^(0),"^",2,4)="3.077^"_%ZTER11N_"^"_%ZTER11N
  1. . . I $D(^%ZTER(3.077,%ZTER11N,0)) S %ZTER11N=0 Q
  1. . . S ^%ZTER(3.077,%ZTER11N,0)=%ZTER11A,^%ZTER(3.077,"B",$E(%ZTER11A,1,30),%ZTER11N)=""
  1. . . Q
  1. . I '$D(^%ZTER(3.077,%ZTER11N,4,0)) S ^(0)="^3.0775"
  1. . S %ZTER11H=$H,%ZTER11S=($P(%ZTER11H,",",2)\3600)+1,%ZTER11H=+%ZTER11H
  1. . S $P(^%ZTER(3.077,%ZTER11N,4,%ZTER11H,0),"~",%ZTER11S)=$P($G(^%ZTER(3.077,%ZTER11N,4,%ZTER11H,0)),"~",%ZTER11S)+1
  1. . I $P($G(^%ZTER(3.077,%ZTER11N,0)),"^",2)="" S $P(^%ZTER(3.077,%ZTER11N,0),"^",2)=$$HTFM^XLFDT($H) ;P582
  1. . S $P(^%ZTER(3.077,%ZTER11N,0),"^",3)=$$HTFM^XLFDT($H) ;P583
  1. . Q
  1. Q
  1. ;
  1. ;Output format 'Tag+offset^Routine, <error code>'
  1. FMT(%ZTE) ;Format the error text
  1. I $E(%ZTE,1,2)="<>" S %ZTE=$E(%ZTE,3,999)
  1. S %ZTE=$TR(%ZTE,"^","~")
  1. I %ZTE["<"&($P(%ZTE,"<",2)[">") S %ZTE=$P($P(%ZTE,">",2)," ")_", "_$P(%ZTE,">")_">"
  1. Q %ZTE
  1. ;
  1. SCREEN(ERR,%ZT3) ;Screen out certain errors.
  1. N %ZTA,%ZTE,%ZTI,%ZTJ,%ZTH,%ZTR S:'$D(ERR) ERR=$$EC^%ZOSV
  1. I '$L(ERR) Q 0 ;Record
  1. ;Set error text format
  1. S %ZTH=+$H,%ZTE=$$FMT(ERR)
  1. ;Find error in summary
  1. S %ZTI=$O(^%ZTER(3.077,"B",$E(%ZTE,1,30),0)),%ZTR=$G(^%ZTER(3.077,+%ZTI,4,%ZTH,0)),%ZTJ=0 ; edit form %ZTE to $E(%ZTE,1,30) p685
  1. F %ZTA=1:1:24 S %ZTJ=%ZTJ+$P(%ZTR,"~",%ZTA)
  1. ;Check the limit on the number of errors to record.
  1. I $P($G(^XTV(8989.3,1,"ZTER")),"^",1)'="",%ZTJ'<(+$P($G(^XTV(8989.3,1,"ZTER"),"10"),"^",1)) Q 1 ;Don't record
  1. ;Check error screens
  1. S %ZTE="",%ZTI=0
  1. ;See if error is in list.
  1. F %ZTJ=2,1 D Q:%ZTI>0
  1. . 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
  1. . Q
  1. ;Next see if we should count the error
  1. 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.
  1. . Q:(%ZTJ=1)&('$G(%ZT3))
  1. . I $P(%ZTE,"^",4) L +^%ZTER(2,%ZTI):10 S ^(3)=$G(^%ZTER(2,%ZTI,3))+1 L -^%ZTER(2,%ZTI)
  1. . Q
  1. Q 0 ;record error
  1. ;
  1. UNWIND ;Unwind stack for new error trap. Called by app code.
  1. S $ECODE="" S $ETRAP="D UNW^%ZTER Q:'$QUIT Q -9" S $ECODE=",U1,"
  1. UNW Q:$ESTACK>1 S $ECODE="" Q
  1. ;
  1. NEWERR() ;Does this OS support the M95 error trapping
  1. Q 1 ;All current M system now support 95 error trapping
  1. ;
  1. ABORT ;Pop the stack all the way.
  1. S $ETRAP="Q:$ST>1 S $ECODE="""" Q"
  1. Q
  1. ;
  1. POST ;Do the post-init