ABC file access and error/errorcode usage

Looking at converting some legacy code to ABC. I have a FormatErrorMessage() function that builds out and returns a string using errorcode(), errorfile(), and error(). This is typically called immediately after checking errorcode() to see if something happened.

For ABC, are the GetErrorcode(errorlevel), GetFilename(), and GetError(errorlevel) what I’m looking for?

The legacy function works from the current ‘state’, but within the ABC world I need to retrieve the file name using GetFilename, then use SetFilename for the ErrorClass, then use GetErrorcode() and GetError() to build out my string?

I understand the Access:Filename.Insert/whatever() could generate messages on its own, but I often need to get in front of the user seeing any messages due to a file I/O issue. So I typically use the Try methods.



Does the ABC file i/o potentially mess with the current error state before I can call PushErrors? I think that was the issue I had in the past. (If PushErrors works after Access:Filename than I don’t need to push/pop the error state if I can directly access it right then.)

It can. Usually the methods that begin with TRY are the safest if you want to preserve the error state.

Look at the errorclass GetErrorCode and GetError methods. You can call these after calling the File Manager methods.