From e8da7baee2078e56cab09eef406f2ef1f1b2a1a3 Mon Sep 17 00:00:00 2001 From: cacaodev Date: Thu, 1 Oct 2015 13:19:40 +0200 Subject: [PATCH] Perform operation on network error (try/catch). --- Foundation/CPURLConnection.j | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Foundation/CPURLConnection.j b/Foundation/CPURLConnection.j index d1b9a6838..52df11606 100644 --- a/Foundation/CPURLConnection.j +++ b/Foundation/CPURLConnection.j @@ -274,6 +274,8 @@ var CPURLConnectionDelegate = nil; { if ([_delegate respondsToSelector:@selector(connection:didFailWithError:)]) [_delegate connection:self didFailWithError:anException]; + else if (_connectionOperation !== nil) + [self _connectionOperationDidReceiveResponse:nil data:nil error:anException]; } /* @@ -340,10 +342,10 @@ var CPURLConnectionDelegate = nil; if (!_isCanceled) { - if (_connectionOperation !== nil) - [self _connectionOperationDidReceiveResponse:response data:_HTTPRequest.responseText() error:nil]; - else if ([_delegate respondsToSelector:@selector(connection:didReceiveData:)]) + if ([_delegate respondsToSelector:@selector(connection:didReceiveData:)]) [_delegate connection:self didReceiveData:_HTTPRequest.responseText()]; + else if (_connectionOperation !== nil) + [self _connectionOperationDidReceiveResponse:response data:_HTTPRequest.responseText() error:nil]; if ([_delegate respondsToSelector:@selector(connectionDidFinishLoading:)]) [_delegate connectionDidFinishLoading:self];