Apple Developer Connection
Member Login Log In | Not a Member? Contact ADC

Next Page > Hide TOC

Introduction to Error Handling Programming Guide For Cocoa

Contents:

Organization of This Document
See Also


Every program must deal with errors as they occur at runtime. The program, for example, might not be able to open a file, or perhaps it cannot parse an XML document. Often errors such as these require the program to inform the user about them. And perhaps the program can attempt to get around the problem causing the error.

Cocoa offers developers programmatic tools for these tasks: the NSError class in Foundation and new methods and mechanisms in the Application Kit to support error handling in applications. An NSError object encapsulates information specific to an error, including the domain (subsystem) originating the error and the localized strings to present in an error alert. With an application there is an also an architecture allowing the various objects in an application to refine the information in an error object and perhaps to recover from the error. This document describes this API and architecture and explains how to use them.

Important: Although the NSError class was introduced in Mac OS X v10.3, several methods have been added to the class and to the Application Kit in Mac OS X v10.4 to support error handling as described in this document.

Organization of This Document

Error Handling Programming Guide for Cocoa has the following articles:

See Also

“Types of Dialogs and When to Use Them” in the Apple Human Interface Guidelines offers advice on the form and content of alerts. You should consult these guidelines before composing your error messages. Also take a look at the following conceptual documents on areas of Cocoa programming related to error handling and the presentation of error messages:

The The Objective-C 2.0 Programming Language, in “Exception Handling and Thread Synchronization”, includes documentation of the compiler directives @try, @catch, @throw, and @finally, which are used in exception handling.



Next Page > Hide TOC


Last updated: 2006-10-03




Did this document help you?
Yes: Tell us what works for you.

It’s good, but: Report typos, inaccuracies, and so forth.

It wasn’t helpful: Tell us what would have helped.
Get information on Apple products.
Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Copyright © 2007 Apple Inc.
All rights reserved. | Terms of use | Privacy Notice