Question
· Mar 11, 2020

Can you have a custom %Status object without the error code in the $SYSTEM.Status.GetErrorText(sc) output ?

There does not seem to be any separation between the error code and error text in a %Status object. For custom errors, I simply want to display the message and not Error #5001: Some error text.

ClassMethod IsNonNullCustomerID(pCustomerID As %String) As %Status  {
Quit:(pCustomerID="") $$$ERROR($$$GeneralError,"CustomerID is not valid")
Quit $$$OK
}

The various methods described here to retrieve the error text always show

Error  #5001: CustomerID not valid

Without manipulating the string above, can you get the "CustomerID not valid" message cleanly from the %Status object and in as few lines of code as possible?

Discussion (5)1
Log in or sign up to continue

Thanks guys! I could not find helper links to these methods in the ADO .NET Managed Provider class Intersystems.Data.CacheTypes.CacheStatus so I have to proxy to these Intersystems methods via my own Helper class 

Class App.Status.Helper Extends %RegisteredObject
{

ClassMethod GetOneStatusText(pStatus As %Status) As %String
{
    Quit $system.Status.GetOneStatusText(pStatus)
}

}


This is because by default, when you have an error status, CacheStatus.Message property contains a string formatted as  Error  #5001: CustomerID not valid
 

There's one odd thing in the documentation (Cache 2018.1.3) under %SYSTEM.Status and that is the method signatures for some of these methods

classmethod GetOneErrorText(statuscode As %Status, index As %Integer, language) as %Boolean
classmethod GetOneStatusText(statuscode As %Status, index As %Integer, language) as %Boolean

Surely, with "Text" in the method name the return type should be a %String? Why does it say %Boolean?!