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.
The various methods described here to retrieve the error text always show
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?
Comments
w $system.Status.GetErrorText(##class(SomeClass).IsNonNullCustomerID("1234"))
This one unexpectedly displays the #ERROR part though.
You can use GetOneStatusText:
USER>w $system.Status.GetErrorText(x)
ERROR #5002: ObjectScript error: <UNDEFINED> *yy
USER>w $system.Status.GetOneStatusText(x)
ObjectScript error: <UNDEFINED> *yy
Yep, this one works fine as long as you don't embed another error using $$$ADDSC or $$$EMBEDSC.
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
{
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