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