NSError should include support for smart / localized parsing of OSError codes

Originator:michael
Number:rdar://12469842 Date Originated:
Status: Resolved:
Product:Mac OS X Product Version:10.8.2 GM
Classification:Other Bug Reproducible:Always
 
We have a custom file manager class in our application, which we use for some key file IO functionality. The purpose of this class is to provide granular progress indication on copies of large files and directories. This is functionality that NSFileManager currently does not have. The class is based primarily on the File Manager interfaces found in CarbonCore.Framework/Files.h. We realize this is deprecated, but it is currently the only viable API on the system for doing granular large file and directory copies with detail progress notification.

This API returns errors in the form of OSStatus error codes, which we parse into a string to show to the user using GetMacOSStatusCommentString. We then construct an error with this string. Unfortunately, the result of doing this is not nearly as user friendly as the strings NSFileManager / NSError provide when copying files. For example, while we get "Insufficient access privileges for operation.", NSFileManager will give a nice, localized explanation like: "You don't have permission", and more importantly will suggest what the user can do to fix this, right in the error message. NSFileManager / NSError also know how to generate strings that include the target being written to, like "Could not write to "myFile.txt" in "myFolder" because you don't have permission."

We would really like to get access to this user-friendly error language in our custom file manager class. The simplest way to do this would be if Apple could expose methods on NSError that can create such friendly error objects, based on information like the UNIX or OSStatus error code, as well as optionally the file name and the operation being done (rename, copy, link, move, etc).

Comments


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!