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

BPSOSUE.m

Go to the documentation of this file.
  1. BPSOSUE ;BHAM ISC/FCS/DRS/FLS - impossible errors ;03/07/08 10:42
  1. ;;1.0;E CLAIMS MGMT ENGINE;**1,7**;JUN 2004;Build 46
  1. ;;Per VHA Directive 2004-038, this routine should not be modified.
  1. ;
  1. ; Deal with impossible errors (errors which should never occur,
  1. ; and which weren't already trapped by M).
  1. ;
  1. IMPOSS(UETYPE,UEOPT,UEMSG,UEMSG2,UELOC,UEROU,UENOLOG) ;EP - deal with impossible errors - called from many places
  1. ; $$IMPOSS^BPSOSUE(UETYPE,UEOPT,UEMSG,UELOC,UEROU)
  1. ; UETYPE = kinds of problems which may have occured
  1. ; ["FM" a Fileman call has returned an error
  1. ; ["L" a LOCK with ample time has failed
  1. ; ["DB" a database error (some missing/incorrect field)
  1. ; ["P" a programming error / some unexpected condition
  1. ; ["DEV" some kind of device or file error
  1. ; UEOPT = options available; first one listed is the default
  1. ; Defaults to "TRI"
  1. ; ["R" retry - retry the operation; log err
  1. ; ["I" ignore - continue as though operation had succeeded; log err
  1. ; ["T" abort - log err and terminate
  1. ; UEMSG = optionally, an additional message to output
  1. ; can be .MSG, and we'll walk the array for you.
  1. ; UEMSG2 = even more message, like UEMSG. In a Fileman call failure,
  1. ; you'd probably send .FDA,.MSG
  1. ; UELOC = location, any number or name unique to the calling routine
  1. ; UEROU = the name of the calling routine
  1. ; UENOLOG = true if you do not want error log entry to be made
  1. ;
  1. ; $$ returns 1 to retry, 0 to ignore
  1. ;
  1. ; Caller may do with these values what he desires.
  1. ;
  1. ; To prevent excessive errors, we won't actually log an error if
  1. ; another one has been logged recently.
  1. ;
  1. ; This routine really isn't as important as it looks. In fact,
  1. ; it will almost never be encountered in practice. Its existence
  1. ; owes mostly to an outrageous ruling made in the name of,
  1. ; but contrary to, the very quality and maintainability that forced
  1. ; errors give you. This in turn led to a significant delay
  1. ; in the release of a product which has been proven to be dependable
  1. ; in practice.
  1. ;
  1. ; Formerly, a zero/zero forced error was found at various places
  1. ; in the code. In 13 months at ANMC, 11 months at Sitka,
  1. ; and several months at Pawhuska, Wewoka, Santa Fe, and Taos, the
  1. ; zero div by zero traps were never encountered, but over $3,000,000
  1. ; in revenues were collected. The ironic thing is,
  1. ; without those extra checking, of things like Fileman return values,
  1. ; sanity checks on input values, etc., the product would have been
  1. ; less reliable, yet it would have sailed through the verifiction
  1. ; phase of the project plan.
  1. ;
  1. ; Forced errors already pervade all of the M language. <UNDEF> is
  1. ; a forced error, for example. And forced errors are an integral part
  1. ; of the design of the very hardware that runs these programs.
  1. ; Follow the anti-forced error policy to its logical end and you
  1. ; go to Intersleaze and say "stop issuing <UNDEF> and instead,
  1. ; prompt the user for the opportunity to continue" and then you go
  1. ; to Intel and say "remove the addressing exception trap from your
  1. ; microcode; our support organization wouldn't be able to cope with
  1. ; the problem report on something like that."
  1. ;
  1. I $G(UEOPT)="" S UEOPT="TRI"
  1. I $G(ZTQUEUED) S UECHOICE=$E(UEOPT) G QD
  1. D:'$D(IOF) HOME^%ZIS ; make sure screen vars there
  1. U IO
  1. I '$D(IORVON) N IORVON,IORVOFF D
  1. . N X S X="IORVON;IORVOFF" D ENDR^%ZISS
  1. W !!,IORVON
  1. W "An unexpected problem has been detected; notify programmer!"
  1. I $D(UELOC)!$D(UEROU) D
  1. . W !?5,"The problem occurred "
  1. . I $D(UELOC) W "at location ",UELOC," " W:$X>60 !
  1. . I $D(UEROU) W "in routine ",UEROU
  1. . W ".",!
  1. W !?5,"The likely source" W:UETYPE["," "s"
  1. W " of such a problem " W $S(UETYPE[",":"are",1:"is"),":",!!?5
  1. I UETYPE["FM" D
  1. . W "Fileman has reported an error to the program.",!?5
  1. I UETYPE["L" D
  1. . W "An interlock could not be obtained.",!?5
  1. I UETYPE["DB" D
  1. . W "An inconsistency in the database was detected.",!?5
  1. I UETYPE["DEV" D
  1. . W "An error condition trying to open a device or a file.",!?5
  1. I UETYPE["P" D
  1. . W "A condition the program was unprepared to handle",!?5
  1. . W "or perhaps an error in the program logic.",!?5
  1. W !,"A programmer should be notified of this unfortunate event.",!
  1. D MSG(.UEMSG),MSG(.UEMSG2)
  1. W IORVOFF,!!
  1. ;
  1. N UECHOICE S UECHOICE=$$CHOICE ; Present the options; get I, R, T
  1. QD ;
  1. D LOGERR ; always log an error (unless too soon after prev. error)
  1. I UECHOICE="T" G HALT
  1. ;LJE;H $R(10)+1 ; could help various things (locks, database conditions)
  1. H 2
  1. Q:$Q $S(UECHOICE="I":0,UECHOICE="R":1) Q
  1. ;
  1. MSG(X) ; display message, directly or in array
  1. I '$D(X) W "X is undefined",! Q
  1. I $D(X)#10 W X,!
  1. I $D(X)>9 D
  1. . N R S R="X" F S R=$Q(@R) Q:R="" W @R,!
  1. W !
  1. Q
  1. ;
  1. CHOICE() ; given UEOPT[letters, UETYPE too
  1. I UEOPT="" S UEOPT="T"
  1. N DIR,X,Y
  1. I $L(UEOPT)=1 S X=UEOPT G CH5
  1. S DIR(0)="SM^",X=""
  1. I UEOPT["I" S X=X_"I:Ignore the problem and try to continue"
  1. I UEOPT["R" S:X]"" X=X_";" S X=X_"R:Retry the operation"
  1. I UEOPT["T" S:X]"" X=X_";" S X=X_"T:Terminate the program"
  1. I UETYPE'="L" S X=X_" (WE RECOMMEND ""T"")"
  1. S DIR(0)=DIR(0)_X
  1. S DIR("B")=$E(UEOPT) D ^DIR
  1. CH5 Q $S(X?1U:X,1:"T")
  1. ;
  1. LOGERR ; log an error
  1. ; ^TMP($J,$T(+0),$J)=DUZ^$H last time we did this
  1. N X S X=$G(^TMP($J,$T(+0),$J))
  1. I $P(X,U)'=DUZ G LOG2
  1. S X=$P(X,U,2) I +$H'=+X G LOG2
  1. S X=$P(X,",",2) I $P($H,",",2)-X>300 G LOG2
  1. I '$G(ZTQUEUED) D
  1. . W !,"No additional error log entry will be made at this time.",!
  1. Q
  1. LOG2 ;
  1. Q:$G(UENOLOG) ; requested: no error log entry
  1. I '$G(ZTQUEUED) D
  1. . W !,"Now recording some error log information to help the programmer...",!
  1. D @^%ZOSF("ERRTN") ; trap an error
  1. S ^TMP($J,$T(+0),$J)=DUZ_U_$H
  1. I '$D(ZTQUEUED) D
  1. . W ?10,"..." H 2 W "done.",!
  1. Q
  1. HALT ; halt
  1. D H^XUS
  1. ; at this point, the user is logged off
  1. ; programmer shouldn't reach here, either, if HALT^ZU disinstackifies
  1. Q "" ; <DPARM> error gets you back into programmer mode
  1. TEST ;
  1. N MYEXMSG,I F I=1:1:4 S MYEXMSG(I)="my extra msg line "_I
  1. N X S X=$$IMPOSS^BPSOSUE("P","TIR","Additional Message",.MYEXMSG,"point 1","MYROU")
  1. W !,"returned value = ",X,!
  1. Q