How to obtain low (OS) level error description in Cache ObjectScript?
Sometimes standard COS methods fails and returns low level error code (like %File(CopyFile) error code "-3").
As per ISC Support response, Cache is negating low level error codes (adding "-" prefix).
Is there any existing COS method or COS code snippet to obtain low level error description based on low level error code (positive or negative)?
On IRIS there's $zu(209,code) - e.g.:
In IRIS 2020.1+ you don't need the $zu:
USER>w $System.Util.GetOSErrorText(3) <3> The system cannot find the path specified.
AFAIK there's no Caché/Ensemble equivalent. (Or maybe this is in newer Caché/Ensemble versions.)
Works even on Caché 2018.1.2. I can't think of a reason as to why it wouldn't work for IRIS CE.
EDIT: Just to point out that GetOSErrorText is indeed limited to 2020.1+ releases, including Caché.
Ack - I meant Caché/Ensemble. Clarified; thanks, and thanks for pointing out that it does work on Caché 2018.1.2.
Thank you- it works.
I wouldn't recommend using ZU commands as they are deprecated so they are not guaranteed to always work.
Errors returned can occasionally be COS error codes, or they might boil down to OS error codes. It depends on the function; I don't know if there's a universal method that differentiates. I think you need to look at what you're calling. Often the class reference gives details on what error codes to expect.
In your particular case, referring to the %Library.File.CopyFile class reference:
"This method returns true if it succeeds and false otherwise. Pass return by reference to obtain the low level return value in case of errors which is the negative value of the operating system return code."