Google Docs iphone library error reporting
- by phil harris
I'm in the process of adding a Google Docs interface to my iPhone app, and I'm largely following the example in the GoogleDocs.m file from Tom Saxton's example app.
The objective-c library I'm using is from http://code.google.com/p/gdata-objectivec-client/wiki/GDataObjCIntroduction
The library file used is from gdata-objectivec-client-1.10.0.zip.
This service:username:password method is a slight variant of the one found in the Saxton file GoogleDocs.m starting at line 351:
- (void)service:(NSString *)username password:(NSString *)password
{
if(service == nil) {
service = [[[GDataServiceGoogleDocs alloc] init] autorelease];
[service setUserAgent:s_strUserAgent];
[service setShouldCacheDatedData:NO];
[service setServiceShouldFollowNextLinks:NO];
(void)[service authenticateWithDelegate:self didAuthenticateSelector:@selector(ticket:authenticatedWithError:)];
}
// update the username/password each time the service is requested
if (username != nil && [username length] && password != nil && [password length])
[service setUserCredentialsWithUsername:username password:password];
else
[service setUserCredentialsWithUsername:nil password:nil];
}
// associated callback for service:username:password: method
- (void)ticket:(GDataServiceTicket *)ticket authenticatedWithError:(NSError *)error
{
NSLog(@"%@",@"authenticatedWithError called");
if(error == nil)
[self selectBackupRestore];
else {
NSLog(@"error code(%d)", [error code]);
NSLog(@"error domain(%d)", [error domain]);
NSLog(@"localizedDescription(%@)", error.localizedDescription);
NSLog(@"localizedFailureReason(%@)", error.localizedFailureReason);
NSLog(@"localizedRecoveryOptions(%@)", error.localizedRecoveryOptions);
NSLog(@"localizedRecoverySuggestion(%@)", error.localizedRecoverySuggestion);
}
}
Please note the service:username:password method and the callback compile and run fine. The problem is that the callback is passing a non-nil NSError object. I added an NSLog() for every error reporting attribute of NSError and the (Xcode) log output of a test run is below.
[Session started at 2010-05-27 12:27:16 -0700.]
2010-05-27 12:27:38.778 iFilebox[74596:207] authenticatedWithError called
2010-05-27 12:27:38.779 iFilebox[74596:207] error code(-1)
2010-05-27 12:27:38.780 iFilebox[74596:207] error domain(499324)
2010-05-27 12:27:38.781 iFilebox[74596:207] localizedDescription(Operation could not be completed. (com.google.GDataServiceDomain error -1.))
2010-05-27 12:27:38.782 iFilebox[74596:207] localizedFailureReason((null))
2010-05-27 12:27:38.782 iFilebox[74596:207] localizedRecoveryOptions((null))
2010-05-27 12:27:38.783 iFilebox[74596:207] localizedRecoverySuggestion((null))
My essential question is in the error reporting. I was hoping the localizedDescription would be more specific of the error. All I get for the error code value is -1, and the only description of the error is "Operation could not be completed. (com.google.GDataServiceDomain error -1.". Not very helpful. Does anyone know what a GDataServiceDomain error -1 is? Where can I find a full list of all error codes returned, and a description of what they mean?