mirror of
https://github.com/zhigang1992/RestKit.git
synced 2026-04-23 04:20:21 +08:00
Added error to method signature and used RKLogError if the errror isn't nil
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user