It is always possible that the framework may encounter an error when performing a task, particularly when communicating with a device. Almost all of the framework methods return either NO or nil to indicate failure, but sometimes it is useful to know exactly what went wrong. Any method that indicates failure also has an error parameter, that can be used to return an NSError object. This object has the following properties:
- errorDomain The domain, as defined by EOSErrorDomain
- code An error code that is defined by the EOSError enumeration
- localizedDescription A string that identifies the type of error (e.g. "Device Error")
- localizedFailureReason A string that explains the error in more detail (e.g. "No disk")
- localizedRecoverySuggestion Currently the same as localizedFailureReason
Example
The following shows an example of attempting to open a camera session and, if unsuccessful, presents an error dialog to the user.//camera is an instance of EOSCamera //declare the NSError object NSError* error; //attempt to open a camera session BOOL success = [camera openSession:&error]; //if unsuccessful if (!success){ //present error to user [NSApp presentError:error]; }The NSApplication's presentError method will, by default, produce a dialog similar to the one below.
