Add configurable error parsing to the object mapper.

This commit is contained in:
Jeremy Ellison
2010-10-14 12:51:12 -04:00
parent 069978ec07
commit 7c01d54fa3
3 changed files with 36 additions and 14 deletions

View File

@@ -101,20 +101,7 @@
[_delegate objectLoader:self didFailWithError:response.failureError];
return YES;
} else if ([response isError]) {
NSString* errorMessage = nil;
if ([response isJSON]) {
// TODO: Processing errors should be moved to a delegate to accommodate non-Rails services...
errorMessage = [[[response bodyAsJSON] valueForKey:@"errors"] componentsJoinedByString:@", "];
}
if (nil == errorMessage) {
errorMessage = [response bodyAsString];
}
NSDictionary *userInfo = [NSDictionary dictionaryWithObjectsAndKeys:
errorMessage, NSLocalizedDescriptionKey,
nil];
NSError *error = [NSError errorWithDomain:RKRestKitErrorDomain code:RKObjectLoaderRemoteSystemError userInfo:userInfo];
[_delegate objectLoader:self didFailWithError:error];
[_delegate objectLoader:self didFailWithError:[_mapper parseErrorFromString:[response bodyAsString]]];
return YES;
}