Published on InterSystems Developer Community (https://community.intersystems.com)

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

Question
Stephen Wilson · 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?

#Error Handling #ObjectScript #Caché

Source URL:https://community.intersystems.com/post/can-you-have-custom-status-object-without-error-code-systemstatusgeterrortextsc-output