<p>If I get an error code result from a Cocoa function, is there any easy way to figure out what it means (other than by grepping through all the .h files in the framework bundles)?</p>

[{'answer_id': 38497, 'author': 'Chris Hanson', 'author_id': 714, 'author_profile': 'https://Stackoverflow.com/users/714', 'pm_score': 6, 'selected': True, 'text': "<p>You should look at the <code>&lt;Framework/FrameworkErrors.h&gt;</code> header for whatever framework the method you're using that's returning an error comes from.</p>\n\n<p>For example, an <code>NSError</code> in the Cocoa domain that you get from a method in the Foundation framework will have its <code>code</code> property described in the <code>&lt;Foundation/FoundationErrors.h&gt;</code> header.  Similarly with AppKit and <code>&lt;AppKit/AppKitErrors.h&gt;</code> and Core Data and <code>&lt;CoreData/CoreDataErrors.h&gt;</code>.</p>\n\n<p>Also, if you print the description of the <code>NSError</code> in the debugger, it should include not only the error domain and code, but also the name of the actual error code constant so you can look it up in the API reference.</p>\n"}, {'answer_id': 71721, 'author': 'Community', 'author_id': -1, 'author_profile': 'https://Stackoverflow.com/users/-1', 'pm_score': 1, 'selected': False, 'text': "<p>Also, Cocoa's NSError is meant to be displayable to the end user.  If you just log it, it should be readable.</p>\n\n<p>If you're talking about Carbon's OSStatus and such, MacErrors.h.</p>\n"}, {'answer_id': 19369662, 'author': 'Mark Amery', 'author_id': 1709587, 'author_profile': 'https://Stackoverflow.com/users/1709587', 'pm_score': 3, 'selected': False, 'text': '<p>The sections on \'Error Domains\' and \'Error Codes\' in Apple\'s <a href="https://developer.apple.com/library/mac/DOCUMENTATION/Cocoa/Conceptual/ErrorHandlingCocoa/ErrorObjectsDomains/ErrorObjectsDomains.html" rel="noreferrer">Error Handling Programming Guide</a> address this reasonably well. You need to do the following:</p>\n<ol>\n<li><p>Log the error, taking note of both the <em>error domain</em> (a human-readable / Googleable string that tells you where to look for the error code definitions) and the <em>error code</em> itself (an integer)</p>\n</li>\n<li><p>Sniff around on Google (or read from the list below) and figure out the name of the header file(s) where the error codes for that error domain are defined</p>\n</li>\n<li><p>Search those header file(s) for the error code you got. You should find both a constant name for the error code (like <code>ENOMEM</code>), and hopefully also an explanatory comment (like <em><code>/* Cannot allocate memory */</code></em>) explaining what the error means. If there\'s no comment, and the constant name isn\'t self-explanatory, just Google the constant name and you\'ll probably find a proper description.</p>\n</li>\n</ol>\n<p>Some header files of major error domains:</p>\n<h2><code>NSCocoaErrorDomain</code></h2>\n<p>Error code declarations are spread across three header files:</p>\n<ul>\n<li><code>&lt;Foundation/FoundationErrors.h&gt;</code> <em>(Generic Foundation error codes)</em></li>\n<li><code>&lt;AppKit/AppKitErrors.h&gt;</code> <em>(Generic AppKit error codes)</em></li>\n<li><code>&lt;CoreData/CoreDataErrors.h&gt;</code> <em>(Core Data error codes)</em></li>\n</ul>\n<h2><code>NSURLErrorDomain</code></h2>\n<p>Check <code>NSURLError.h</code></p>\n<h2><code>NSXMLParserErrorDomain</code></h2>\n<p>Check<code>NSXMLParser.h</code></p>\n<h2><code>NSMachErrorDomain</code></h2>\n<p>Check <code>/usr/include/mach/kern_return.h</code></p>\n<h2><code>NSPOSIXErrorDomain</code></h2>\n<p>Check <code>/usr/include/sys/errno.h</code></p>\n<h2><code>NSOSStatusErrorDomain</code></h2>\n<p>Check</p>\n<pre class="lang-none prettyprint-override"><code>/System/Library/Frameworks/CoreServices.framework/Frameworks/CarbonCore.framework/Headers/MacErrors.h\n</code></pre>\n'}, {'answer_id': 24833116, 'author': 'Will', 'author_id': 1299429, 'author_profile': 'https://Stackoverflow.com/users/1299429', 'pm_score': 0, 'selected': False, 'text': '<p>For NSError errors add a line of code:</p>\n\n<pre><code>NSError     *error;\n\n// ... Some code that returns an error\n\n// Get the error as a string\nNSString *s = [error localizedDescription];\n\n// Observe the code for yourself or display to the user.   \n</code></pre>\n'}]
['https://Stackoverflow.com/questions/38357', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/1175/']