@@ -32,6 +32,10 @@ - (id) initWithDatabase: (CouchDatabase*)db result: (id)result;
3232@end
3333
3434
35+ @interface CouchQuery ()
36+ @property (readwrite ,retain ) NSError *error;
37+ @end
38+
3539
3640@implementation CouchQuery
3741
@@ -63,13 +67,14 @@ - (void) dealloc
6367 [_startKeyDocID release ];
6468 [_endKeyDocID release ];
6569 [_keys release ];
70+ [_error release ];
6671 [super dealloc ];
6772}
6873
6974
7075@synthesize limit=_limit, skip=_skip, descending=_descending, startKey=_startKey, endKey=_endKey,
7176 prefetch=_prefetch, keys=_keys, groupLevel=_groupLevel, startKeyDocID=_startKeyDocID,
72- endKeyDocID=_endKeyDocID, stale=_stale, sequences=_sequences;
77+ endKeyDocID=_endKeyDocID, stale=_stale, sequences=_sequences, error=_error ;
7378
7479
7580- (CouchDesignDocument*) designDocument {
@@ -142,10 +147,11 @@ - (CouchQueryEnumerator*) rowsIfChanged {
142147
143148
144149- (NSError *) operation : (RESTOperation*)op willCompleteWithError : (NSError *)error {
145- error = [super operation: op willCompleteWithError: error];
146- if (error)
147- Warn (@" %@ failed with %@ " , self, error);
148- if (!error && op.httpStatus == 200 ) {
150+ self.error = [super operation: op willCompleteWithError: error];
151+ if (_error)
152+ Warn (@" %@ failed with %@ " , self, _error);
153+
154+ if (!_error && op.httpStatus == 200 ) {
149155 NSDictionary * result = $castIf (NSDictionary , op.responseBody .fromJSON );
150156 NSArray * rows = $castIf (NSArray , [result objectForKey: @" rows" ]);
151157 if (rows) {
@@ -154,10 +160,12 @@ - (NSError*) operation: (RESTOperation*)op willCompleteWithError: (NSError*)erro
154160 result: result] autorelease ];
155161 } else {
156162 Warn (@" Couldn't parse rows from CouchDB view response" );
157- error = [RESTOperation errorWithHTTPStatus: 502 message: nil URL: self .URL];
163+ self.error = [RESTOperation errorWithHTTPStatus: 502
164+ message: @" Couldn't parse rows from CouchDB view response"
165+ URL: self .URL];
158166 }
159167 }
160- return error ;
168+ return _error ;
161169}
162170
163171
0 commit comments