Update the description about this error code, and fix one potential issue of callback

This commit is contained in:
DreamPiggy 2019-04-11 21:57:04 +08:00
parent c228eb5bdc
commit 7057e70cd5
2 changed files with 4 additions and 1 deletions

View File

@ -128,6 +128,8 @@ typedef NSMutableDictionary<NSString *, id> SDCallbacksDictionary;
@synchronized (self) {
if (self.isCancelled) {
self.finished = YES;
// Operation cancelled by user before sending the request
[self callCompletionBlocksWithError:[NSError errorWithDomain:SDWebImageErrorDomain code:SDWebImageErrorDownloadCancelled userInfo:nil]];
[self reset];
return;
}
@ -226,6 +228,7 @@ typedef NSMutableDictionary<NSString *, id> SDCallbacksDictionary;
if (self.isExecuting) self.executing = NO;
if (!self.isFinished) self.finished = YES;
} else {
// Operation cancelled by user before sending the request
[self callCompletionBlocksWithError:[NSError errorWithDomain:SDWebImageErrorDomain code:SDWebImageErrorDownloadCancelled userInfo:nil]];
}

View File

@ -19,5 +19,5 @@ typedef NS_ERROR_ENUM(SDWebImageErrorDomain, SDWebImageError) {
SDWebImageErrorCacheNotModified = 1002, // The remote location specify that the cached image is not modified, such as the HTTP response 304 code. It's useful for `SDWebImageRefreshCached`
SDWebImageErrorInvalidDownloadOperation = 2000, // The image download operation is invalid, such as nil operation or unexpected error occur when operation initialized
SDWebImageErrorInvalidDownloadStatusCode = 2001, // The image download response a invalid status code. You can check the status code in error's userInfo under `SDWebImageErrorDownloadStatusCodeKey`
SDWebImageErrorDownloadCancelled = 2002, // The image download operation is cancelled by user.
SDWebImageErrorDownloadCancelled = 2002, // The image download operation is cancelled by user before sending the request
};