Hi, I wrote some code to access the ^ERROR global from a character based screen some years ago because the GUI was too slow and cumbersome. There's too much code to share on here but I can give you some direction on the global layout:
The location of ^ERRORS varies between current namespace and %SYS. I haven't looked in to why, it might be due to Caché version. This full program works from Caché 5 through to 2018.
ClassMethod START(test = 0) As %String { S NSP=$ZNSPACE,%ENSP=NSP ; Error global namespace could be "%SYS" or local namespace, haven't worked out how it changes I test S NSP="%SYS",%ENSP=NSP ; ; work out where the ^ERRORS global is i $D(^ERRORS) { ; it's in the current namespace S %ENSP=NSP ; location of the error global } ElseIf $D(^["%SYS"]ERRORS) { S %ENSP="%SYS" } ; count the number of errors for this namespace by date. Date is $H S Date="" F { S Date=$O(^[%ENSP]ERRORS(Date),-1) q:Date=""
Errors with a date are given a sequence number starting at 1 for the first error
{ S ERN="" F { S ERN=$O(^[%ENSP]ERRORS(Date,ERN)) Q:ERN="" ; STACK 0 has got most of what we need to see right now S NSPACE=$g(^[%ENSP]ERRORS(Date,ERN,"*STACK",0,"V","$ZU( 5)")) I NSP=NSPACE,$I(COUNT) { ; sort by time, latest to earliest ; stack 0 contains environment variables like $I, $J, etc. S Time=$g(^[%ENSP]ERRORS(Date,ERN,"*STACK",0,"V","$H")) S Username=$g(^[%ENSP]ERRORS(Date,ERN,"*STACK",0,"V","$USERNAME")) S ZE=$g(^[%ENSP]ERRORS(Date,ERN,"*STACK",0,"V","$ZE"))
Further stack levels contain variables (including arrays and objects) and other stack information
S changePoint=$G(^[%ENSP]ERRORS(Date,ERN,"*STACK",Stack,"L")) s var=$o(^[%ENSP]ERRORS(Date,ERN,"*STACK",Stack,"V",var),1,value) q:var="" i $D(^[%ENSP]ERRORS(Date,ERN,"*STACK",Stack,"V",var))#2 { s ZR=$ZR i $p(value,"0 ",2)'="",..ListValid($p(value,"0 ",2)) { ; looks like a status code //" "_var_" = (status code - fail...)") } else { // (" "_var_" = "_value) } i value["<OBJECT REFERENCE>[" { d ..ShowObject(ScreenObj3,ZR,.i,0) } } // Variables that are arrays i $D(^[%ENSP]ERRORS(Date,ERN,"*STACK",Stack,"V",var,"N"))>1{ s subs="" f j=1:1 { s subs=$O(^[%ENSP]ERRORS(Date,ERN,"*STACK",Stack,"V",var,"N",subs),1,value) q:subs="" //(" "_var_"("_subs_") = "_value))
Objects are stored thus
ClassMethod ShowObject(ScreenObj3 As ZSS.Screen, ZRef, ByRef i, expand = 1) { S Date=$QS(ZRef,1) S ERN=$QS(ZRef,2) S Stack=$QS(ZRef,4) S var=$QS(ZRef,6) S value=@ZRef ; should be immediately followed by "OREF",1)=no of lines ; and "OREF",1,0)=something I don't know - could be a character count ; then loads of rows where each line is terminated by $C(13,10) ; re-add with expand/collapse marker s sign=$s(expand:" - ",1:" + ") //$LB(sign_var_" = "_value),$LB("OBJECT",ZRef)) i expand { s row="" f line=1:1:$G(^[%ENSP]ERRORS(Date,ERN,"*STACK",Stack,"V",var,"OREF",1)) { s row=row_$G(^[%ENSP]ERRORS(Date,ERN,"*STACK",Stack,"V",var,"OREF",1,line)) i $E(row,$l(row)-1,9999)=$c(13,10) { //$LB(" "_$e(row,0,$l(row)-2))) s row="" } } }
Once you've understood the global layout it wouldn't take a lot to kill off dates that you are not interested in any longer. I haven't needed to.
You are using GOTO after an error in programmer mode while debugging. After an error that stops execution the GOTO will just go to the next command. I haven't re-created what you did. My guess is that the existing value of $TEST is 1 (true) and is unaltered by the IF command that failed which means that the interpreter is happy that the next command is SET command. Ensure you define variable x with something sensible and/or write some code to check its value before using it. Alternatively, nest the whole thing in a TRY:CATCH construct to deal with the error.
It doesn't look like you are doing anything wrong but there must be something in the compiler that doesn't like you.
$Name hates class parameters but seems OK if you @ it