Status ErrorList parameter: When using $SYSTEM.Status.DecomposeStatus(tSC, .tErrorList) what is the type of tErrorList returned and how to intialize?

Primary tabs

ObjectScript, Caché

When using $SYSTEM.Status.DecomposeStatus(tSC, .tErrorList) in ObjectScript to get the lsit of errors (I need to do this so that I can generate a custom JSON with the error messages) what is the type of tErrorList returned and how to intialize?

I need to know the type to iterate through it, I have tried dynamic array methods sich as %Size() also $LISTLENGTH to get the size, but both fails, so obviously not that, and being new to InterSystems I find the documentation assumes a new person knows what is behind the classes and how it was implemented from the start. The documentation of the does not state at all what the type of errorlist is, the documentation. Also it is "ByRef" so I need to initialize it to something before calling DecomposeStatus()?:

classmethod DecomposeStatus(statuscode As %Status, ByRef errorlist, qspec, language) as %Status

Returns the error text and error information for statuscode. The information is returned through the errorlist parameter. If the qspec parameter contains "d" flag, then the error text is also displayed to the screen. The user can also specify the language in which the error text is returned using language parameter.
  • 0
  • 0
  • 40
  • 0
  • 2

Answers

ClassMethod LogException(
tAbsException As %Exception.AbstractException) As %Status
{
    
Do $System.Status.DecomposeStatus(tAbsException.AsStatus(), .errorList)
    For i=1:1:errorList {
                    Set fullError = errorlist(i)
                    Set tErrorCode = errorList(i, "code") 
                    You can get caller, domain, params etc from it too, 
                    Just print one errorList and you will see the values of your own error
                    Let me know if you need any help

                  }
    }

The  tErrorList is returned as an array.

tErrorList itself (without index) is an increment counter for decomposed stati. The entry tErrorList(i) contains an array with the information with indices "caller", "code", "dcode", "domain", "namespace", "param", "stack" and others. You can inspect it in the console easily using zw tErrorList or go through it using $order() or $query()

If uninitialized the array it will be created.

If initialized to something other than an array it will be killed and a new array created.

If initialized to an appropiate array (e.g. by previous calls of DecomposeStatus()) the error listings will be appended and the counter incremented.

 

HTH

Matthias