Permalink
Browse files

Make sure errors are forwarded to the response delegate.

  • Loading branch information...
1 parent d94b691 commit 96ad082eef0d3c4c2c1d3d267b8d1857c1206eb9 @lukeredpath committed Aug 2, 2011
Showing with 19 additions and 0 deletions.
  1. +7 −0 Classes/LRRestyClientProxyDelegate.m
  2. +12 −0 Classes/LRRestyClientResponseDelegate.h
@@ -51,4 +51,11 @@ - (void)restyRequest:(LRRestyRequest *)request didFinishWithResponse:(LRRestyRes
[responseDelegate restClient:restyClient receivedResponse:response];
}
+- (void)restyRequest:(LRRestyRequest *)request didFailWithError:(NSError *)error
+{
+ if ([responseDelegate respondsToSelector:@selector(restClient:request:didFailWithError:)]) {
+ [responseDelegate restClient:restyClient request:request didFailWithError:error];
+ }
+}
+
@end
@@ -17,19 +17,23 @@
* response handling.
*/
@protocol LRRestyClientResponseDelegate <NSObject>
+
/**
* Returns the received response
* @param client The client performing the request.
* @param response The received response.
*/
- (void)restClient:(LRRestyClient *)client receivedResponse:(LRRestyResponse *)response;
+
@optional
+
/**
* Called before the request is added to the operation queue
* @param client The client performing the request.
* @param request The request about to be performed.
*/
- (void)restClient:(LRRestyClient *)client willPerformRequest:(LRRestyRequest *)request;
+
/**
* Called every time a chunk of data is received from the server.
* This can be useful when dealing with streaming APIs.
@@ -38,4 +42,12 @@
* @param data The chunk of data received.
*/
- (void)restClient:(LRRestyClient *)client request:(LRRestyRequest *)request receivedData:(NSData *)data;
+
+/**
+ * Called whenever a request fails.
+ * @param client The client performing the request.
+ * @param request The request that failed.
+ * @param error The request error.
+ */
+- (void)restClient:(LRRestyClient *)client request:(LRRestyRequest *)request didFailWithError:(NSError *)error;
@end

0 comments on commit 96ad082

Please sign in to comment.