Return JSON error or HTTP error.

This commit is contained in:
Dustin Barker 2011-10-19 22:33:09 -07:00
parent 810096b37d
commit b906b62c59

View file

@ -37,7 +37,7 @@ static dispatch_queue_t json_request_operation_processing_queue() {
@interface AFJSONRequestOperation ()
@property (readwrite, nonatomic, retain) id responseJSON;
@property (readwrite, nonatomic, retain) NSError *error;
@property (readwrite, nonatomic, retain) NSError *JSONError;
+ (NSSet *)defaultAcceptableContentTypes;
+ (NSSet *)defaultAcceptablePathExtensions;
@ -45,7 +45,7 @@ static dispatch_queue_t json_request_operation_processing_queue() {
@implementation AFJSONRequestOperation
@synthesize responseJSON = _responseJSON;
@synthesize error = _JSONError;
@synthesize JSONError = _JSONError;
+ (AFJSONRequestOperation *)JSONRequestOperationWithRequest:(NSURLRequest *)urlRequest
success:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, id JSON))success
@ -129,12 +129,20 @@ static dispatch_queue_t json_request_operation_processing_queue() {
#endif
}
self.error = error;
self.JSONError = error;
}
return _responseJSON;
}
- (NSError *)error {
if (_JSONError) {
return _JSONError;
} else {
return [super error];
}
}
#pragma mark - AFHTTPClientOperation
+ (BOOL)canProcessRequest:(NSURLRequest *)request {