@@ -168,14 +168,14 @@ - (void)_cancelImageDownload
168168 _cacheUUID = nil ;
169169}
170170
171- - (void )_downloadImageWithCompletion : (void (^)(CGImageRef))finished
171+ - (void )_downloadImageWithCompletion : (void (^)(CGImageRef, NSError * ))finished
172172{
173173 _imageDownload = [_downloader downloadImageWithURL: _URL
174174 callbackQueue: dispatch_get_main_queue ()
175175 downloadProgressBlock: NULL
176176 completion: ^(CGImageRef responseImage, NSError *error) {
177177 if (finished != NULL ) {
178- finished (responseImage);
178+ finished (responseImage, error );
179179 }
180180 }];
181181}
@@ -210,7 +210,7 @@ - (void)_lazilyLoadImageIfNecessary
210210 }
211211 } else {
212212 __weak __typeof__ (self) weakSelf = self;
213- void (^finished)(CGImageRef) = ^(CGImageRef responseImage) {
213+ void (^finished)(CGImageRef, NSError * ) = ^(CGImageRef responseImage, NSError *error ) {
214214 __typeof__ (self) strongSelf = weakSelf;
215215 if (strongSelf == nil ) {
216216 return ;
@@ -232,6 +232,9 @@ - (void)_lazilyLoadImageIfNecessary
232232 if (responseImage != NULL ) {
233233 [strongSelf->_delegate imageNode: strongSelf didLoadImage: strongSelf.image];
234234 }
235+ else if (error && [strongSelf->_delegate respondsToSelector: @selector (imageNode:didFailWithError: )]) {
236+ [strongSelf->_delegate imageNode: strongSelf didFailWithError: error];
237+ }
235238 };
236239
237240 if (_cache != nil ) {
@@ -247,7 +250,7 @@ - (void)_lazilyLoadImageIfNecessary
247250 if (image == NULL && _downloader != nil ) {
248251 [self _downloadImageWithCompletion: finished];
249252 } else {
250- finished (image);
253+ finished (image, NULL );
251254 }
252255 };
253256
0 commit comments