Question

The file handling in Cocoa is quite simple, several of the classes handle messages as the following (e.g. NSData)

writeToURL:options:error:

But the documentation of the error statement is quite useless. Just "NSError object that describes the problem"

Ok but where are all the possible errors documented? Did I miss the relevant link? I expect the list is not endless.

Was it helpful?

Solution

You may have noticed that an instance of NSError includes a property called domain. This is a string, three of which are defined: NSPOSIXErrorDomain, NSOSStatusErrorDomain, and NSMachErrorDomain. Each domain has error codes unique to it, or at least have special meaning in their contexts.

For NSPOSIXErrorDomain, look in sys/errno.h.

Likewise, for NSOSStatusErrorDomain, look in CarbonCore/MacErrors.h.

For NSMachErrorDomain, look in mach/error.h.

Frameworks can define their own domains, and an example of this is NSCocoaErrorDomain, for which you should look in Foundation/FoundationErrors.h.

Keep in mind that you can define your own error domains and codes you in your own projects.

Good luck to you in your endeavors.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top