Merge pull request #84 from dstnbrkr/return-http-error-or-json-error
Return JSON error or HTTP error.
This commit is contained in:
commit
67d8d043c9
1 changed files with 11 additions and 3 deletions
|
|
@ -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 {
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue