Merge pull request #3005 from dreampiggy/error_decode_failed

Polish the error description between image decode failed and image size is 0
This commit is contained in:
DreamPiggy 2020-05-09 10:53:19 +08:00 committed by GitHub
commit 1d1c3407a7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 1 deletions

View File

@ -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];
}