Merge pull request #84 from dstnbrkr/return-http-error-or-json-error

Return JSON error or HTTP error.
This commit is contained in:
Mattt Thompson 2011-10-21 09:12:53 -07:00
commit 67d8d043c9

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 {