mirror of
https://github.com/zhigang1992/PINRemoteImage.git
synced 2026-01-12 22:49:34 +08:00
Add error for empty images. (#188)
This commit is contained in:
@@ -35,6 +35,8 @@ typedef NS_ENUM(NSUInteger, PINRemoteImageManagerError) {
|
||||
PINRemoteImageManagerErrorFailedToProcessImage = 3,
|
||||
/** The image in the cache was invalid */
|
||||
PINRemoteImageManagerErrorInvalidItemInCache = 4,
|
||||
/** The image at the URL was empty */
|
||||
PINRemoteImageManagerErrorImageEmpty = 5,
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@@ -802,18 +802,25 @@ static dispatch_once_t sharedDispatchToken;
|
||||
#if PINRemoteImageLogging
|
||||
if (error && error.code != NSURLErrorCancelled) {
|
||||
PINLog(@"Failed downloading image: %@ with error: %@", url, error);
|
||||
} else if (error == nil && responseObject == nil) {
|
||||
} else if (error == nil && response.expectedContentLength == 0) {
|
||||
PINLog(@"image is empty at URL: %@", url);
|
||||
} else {
|
||||
PINLog(@"Finished downloading image: %@", url);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (error.code != NSURLErrorCancelled) {
|
||||
[strongSelf lock];
|
||||
PINRemoteImageDownloadTask *task = [strongSelf.tasks objectForKey:key];
|
||||
NSData *data = task.progressImage.data;
|
||||
[strongSelf unlock];
|
||||
|
||||
if (error == nil && data == nil) {
|
||||
error = [NSError errorWithDomain:PINRemoteImageManagerErrorDomain
|
||||
code:PINRemoteImageManagerErrorImageEmpty
|
||||
userInfo:nil];
|
||||
}
|
||||
|
||||
completion(data, error);
|
||||
}
|
||||
}];
|
||||
|
||||
Reference in New Issue
Block a user