From 87f2418b0e88d27c360d306f9413a934be4aef69 Mon Sep 17 00:00:00 2001 From: DreamPiggy Date: Fri, 8 May 2020 18:34:32 +0800 Subject: [PATCH] Polish the error description between image decode failed and image size is 0 --- SDWebImage/Core/SDWebImageDownloaderOperation.m | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/SDWebImage/Core/SDWebImageDownloaderOperation.m b/SDWebImage/Core/SDWebImageDownloaderOperation.m index 00d803f2..57ac0571 100644 --- a/SDWebImage/Core/SDWebImageDownloaderOperation.m +++ b/SDWebImage/Core/SDWebImageDownloaderOperation.m @@ -474,7 +474,8 @@ didReceiveResponse:(NSURLResponse *)response UIImage *image = SDImageLoaderDecodeImageData(imageData, self.request.URL, [[self class] imageOptionsFromDownloaderOptions:self.options], self.context); CGSize imageSize = image.size; if (imageSize.width == 0 || imageSize.height == 0) { - [self callCompletionBlocksWithError:[NSError errorWithDomain:SDWebImageErrorDomain code:SDWebImageErrorBadImageData userInfo:@{NSLocalizedDescriptionKey : @"Downloaded image has 0 pixels"}]]; + NSString *description = image == nil ? @"Downloaded image decode failed" : @"Downloaded image has 0 pixels"; + [self callCompletionBlocksWithError:[NSError errorWithDomain:SDWebImageErrorDomain code:SDWebImageErrorBadImageData userInfo:@{NSLocalizedDescriptionKey : description}]]; } else { [self callCompletionBlocksWithImage:image imageData:imageData error:nil finished:YES]; }