Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I view an NSError?

People also ask

What is NSError domain?

The core attributes of an NSError object—or, simply, an error object—are an error domain, a domain-specific error code, and a “user info” dictionary containing objects related to the error, most significantly description and recovery strings.

What is made up of NSError object?

The core attributes of an NSError object are an error domain (represented by a string), a domain-specific error code and a user info dictionary containing application specific information.

What is the latest version of Objective C?

The latest version of objective C is 2.0.


Looking at the NSError documentation tells me that you'll need to do something like:

NSLog(@"%@",[error localizedDescription]);

This should then give you human readable output


NSLog(@"Error: %@", error);

Gives me a null message

Then error is nil, not an NSError instance.


Here's a rough method I use to log errors while developing; (Not for Cocoa-touch)

// Execute the fetch request put the results into array
NSError *error = nil;
NSArray *resultArray = [moc executeFetchRequest:request error:&error];
if (resultArray == nil)
{
    // Diagnostic error handling
    NSAlert *anAlert = [NSAlert alertWithError:error];
    [anAlert runModal];
}

NSAlert takes care of displaying the error.