Added error to method signature and used RKLogError if the errror isn't nil

This commit is contained in:
Leon
2011-06-15 14:51:56 +02:00
parent 2c5700fded
commit 550edf9873
2 changed files with 3 additions and 4 deletions

View File

@@ -92,7 +92,7 @@
/**
* Return the response body parsed as JSON into an object
*/
- (id)parsedBody;
- (id)parsedBody:(NSError*)error;
/**
* Will determine if there is an error object and use it's localized message

View File

@@ -149,12 +149,11 @@ extern NSString* cacheURLKey;
return nil;
}
- (id)parsedBody {
- (id)parsedBody:(NSError*)error {
id<RKParser> parser = [[RKParserRegistry sharedRegistry] parserForMIMEType:[self contentType]];
NSError *error;
id object = [parser objectFromString:[self bodyAsString] error:&error];
if (error == nil) {
// TODO throw parse error?
RKLogError(@"Unable to parse response body: %@", [error localizedDescription]);
return nil;
}
return object;