Contents

NSError

Information about an error condition including a domain, a domain-specific error code, and application-specific information.

Declaration

class NSError

Overview

Objective-C methods can signal an error condition by returning an NSError object by reference, which provides additional information about the kind of error and any underlying cause, if one can be determined. An NSError object may also provide localized error descriptions suitable for display to the user in its user info dictionary. See Error Handling Programming Guide for more information.

Methods in Foundation and other Cocoa frameworks most often produce errors in the Cocoa error domain (NSCocoaErrorDomain); error codes for the Cocoa Error Domain are documented in the Foundation Constants. There are also predefined domains corresponding to Mach (NSMachErrorDomain), POSIX (NSPOSIXErrorDomain), and Carbon (NSOSStatusErrorDomain) errors.

NSError is “toll-free bridged” with its Core Foundation counterpart, CFError. See Toll-Free Bridging for more information.

Subclassing Notes

Applications may choose to create subclasses of NSError, for example, to provide better localized error strings by overriding localizedDescription.

Topics

Creating Error Objects

Getting Error Properties

Getting a Localized Error Description

Providing Error User Info

Getting the Error Recovery Attempter

Displaying a Help Anchor

Supporting Types

Error Domains

Error Codes

Initializers

Instance Properties

Type Methods

See Also

User-Relevant Errors