MAGUTERR ;WOIFO/MLH - Imaging - utility - error trap / log with Unix-style codes ; 2/22/2013 9:24 am
;;3.0;IMAGING;**138**;Mar 19, 2002;Build 5380;Sep 03, 2013
;; Per VHA Directive 2004-038, this routine should not be modified.
;; +---------------------------------------------------------------+
;; | Property of the US Government. |
;; | No permission to copy or redistribute this software is given. |
;; | Use of unreleased versions of this software requires the user |
;; | to execute a written test agreement with the VistA Imaging |
;; | Development Office of the Department of Veterans Affairs, |
;; | telephone (301) 734-0100. |
;; | The Food and Drug Administration classifies this software as |
;; | a medical device. As such, it may not be changed in any way. |
;; | Modifications to this software may result in an adulterated |
;; | medical device under 21CFR820, the use of which is considered |
;; | to be a violation of US Federal Statutes. |
;; +---------------------------------------------------------------+
;;
Q ;
; Based on MAGGTERR by GEK
; Imaging routines should have this code for setting a Unix-style
; error code (-1) and logging it in the error trap
;To set into MAGRY() (local array by direct literal reference)
;N $ETRAP,$ESTACK S $ETRAP="D ERRA^MAGUTERR"
;
;To set into @MAGRY@() (local or global array by partial indirection)
;N $ETRAP,$ESTACK S $ETRAP="D AERRA^MAGUTERR"
;
;To set into MAGRY (scalar by direct literal reference)
;N $ETRAP,$ESTACK S $ETRAP="D ERR^MAGUTERR"
;
Q
ERRA ; ERROR TRAP FOR Array Return variables
N ERR S ERR=$$EC^%ZOSV
S MAGRY(0)="-1^^ERROR "_ERR
D LOGERR(ERR)
D @^%ZOSF("ERRTN")
Q
;
AERRA ; ERROR TRAP FOR Global Return Variables
N ERR S ERR=$$EC^%ZOSV
S @MAGRY@(0)="-1^^ERROR "_ERR
D LOGERR(ERR)
D @^%ZOSF("ERRTN")
Q
ERR ; ERROR TRAP FOR String Return variables
N ERR S ERR=$$EC^%ZOSV
S MAGRY="-1^^ERROR "_ERR
D LOGERR(ERR)
D @^%ZOSF("ERRTN")
Q
LOGERR(ERROR) ;
Q:'$G(MAGJOB("SESSION"))
N SESS,WRKS,ERR
S SESS=$G(MAGJOB("SESSION"))
; Quit if No entry in Session File.
Q:'$D(^MAG(2006.82,SESS,0))
I '$D(^MAG(2006.82,SESS,"ERR",0)) S ^MAG(2006.82,SESS,"ERR",0)="^2006.823A^0^0"
S ERR=$O(^MAG(2006.82,SESS,"ERR"," "),-1)+1
S ^MAG(2006.82,SESS,"ERR",ERR,0)=ERROR
S $P(^MAG(2006.82,SESS,"ERR",0),"^",3,4)=ERR_"^"_ERR
;
Q:'$G(MAGJOB("WRKSIEN"))
S WRKS=$G(MAGJOB("WRKSIEN"))
; Quit if No entry in Workstation File.
Q:'$D(^MAG(2006.81,WRKS,0))
S $P(^MAG(2006.81,WRKS,0),"^",11)=ERR
Q
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HMAGUTERR 2679 printed Dec 13, 2024@02:09:03 Page 2
MAGUTERR ;WOIFO/MLH - Imaging - utility - error trap / log with Unix-style codes ; 2/22/2013 9:24 am
+1 ;;3.0;IMAGING;**138**;Mar 19, 2002;Build 5380;Sep 03, 2013
+2 ;; Per VHA Directive 2004-038, this routine should not be modified.
+3 ;; +---------------------------------------------------------------+
+4 ;; | Property of the US Government. |
+5 ;; | No permission to copy or redistribute this software is given. |
+6 ;; | Use of unreleased versions of this software requires the user |
+7 ;; | to execute a written test agreement with the VistA Imaging |
+8 ;; | Development Office of the Department of Veterans Affairs, |
+9 ;; | telephone (301) 734-0100. |
+10 ;; | The Food and Drug Administration classifies this software as |
+11 ;; | a medical device. As such, it may not be changed in any way. |
+12 ;; | Modifications to this software may result in an adulterated |
+13 ;; | medical device under 21CFR820, the use of which is considered |
+14 ;; | to be a violation of US Federal Statutes. |
+15 ;; +---------------------------------------------------------------+
+16 ;;
+17 ;
QUIT
+18 ; Based on MAGGTERR by GEK
+19 ; Imaging routines should have this code for setting a Unix-style
+20 ; error code (-1) and logging it in the error trap
+21 ;To set into MAGRY() (local array by direct literal reference)
+22 ;N $ETRAP,$ESTACK S $ETRAP="D ERRA^MAGUTERR"
+23 ;
+24 ;To set into @MAGRY@() (local or global array by partial indirection)
+25 ;N $ETRAP,$ESTACK S $ETRAP="D AERRA^MAGUTERR"
+26 ;
+27 ;To set into MAGRY (scalar by direct literal reference)
+28 ;N $ETRAP,$ESTACK S $ETRAP="D ERR^MAGUTERR"
+29 ;
+30 QUIT
ERRA ; ERROR TRAP FOR Array Return variables
+1 NEW ERR
SET ERR=$$EC^%ZOSV
+2 SET MAGRY(0)="-1^^ERROR "_ERR
+3 DO LOGERR(ERR)
+4 DO @^%ZOSF("ERRTN")
+5 QUIT
+6 ;
AERRA ; ERROR TRAP FOR Global Return Variables
+1 NEW ERR
SET ERR=$$EC^%ZOSV
+2 SET @MAGRY@(0)="-1^^ERROR "_ERR
+3 DO LOGERR(ERR)
+4 DO @^%ZOSF("ERRTN")
+5 QUIT
ERR ; ERROR TRAP FOR String Return variables
+1 NEW ERR
SET ERR=$$EC^%ZOSV
+2 SET MAGRY="-1^^ERROR "_ERR
+3 DO LOGERR(ERR)
+4 DO @^%ZOSF("ERRTN")
+5 QUIT
LOGERR(ERROR) ;
+1 if '$GET(MAGJOB("SESSION"))
QUIT
+2 NEW SESS,WRKS,ERR
+3 SET SESS=$GET(MAGJOB("SESSION"))
+4 ; Quit if No entry in Session File.
+5 if '$DATA(^MAG(2006.82,SESS,0))
QUIT
+6 IF '$DATA(^MAG(2006.82,SESS,"ERR",0))
SET ^MAG(2006.82,SESS,"ERR",0)="^2006.823A^0^0"
+7 SET ERR=$ORDER(^MAG(2006.82,SESS,"ERR"," "),-1)+1
+8 SET ^MAG(2006.82,SESS,"ERR",ERR,0)=ERROR
+9 SET $PIECE(^MAG(2006.82,SESS,"ERR",0),"^",3,4)=ERR_"^"_ERR
+10 ;
+11 if '$GET(MAGJOB("WRKSIEN"))
QUIT
+12 SET WRKS=$GET(MAGJOB("WRKSIEN"))
+13 ; Quit if No entry in Workstation File.
+14 if '$DATA(^MAG(2006.81,WRKS,0))
QUIT
+15 SET $PIECE(^MAG(2006.81,WRKS,0),"^",11)=ERR
+16 QUIT