Iggy Drougge 3 лет назад
Родитель
Сommit
964b62d616
1 измененных файлов с 6 добавлено и 11 удалено
  1. 6 11
      Sources/Cache/ImageCache.swift

+ 6 - 11
Sources/Cache/ImageCache.swift

@@ -609,12 +609,10 @@ open class ImageCache {
                     image = options.cacheSerializer.image(with: data, options: options)
                     image = options.cacheSerializer.image(with: data, options: options)
                 }
                 }
                 callbackQueue.execute { completionHandler(.success(image)) }
                 callbackQueue.execute { completionHandler(.success(image)) }
+            } catch let error as KingfisherError {
+                callbackQueue.execute { completionHandler(.failure(error)) }
             } catch {
             } catch {
-                if let error = error as? KingfisherError {
-                    callbackQueue.execute { completionHandler(.failure(error)) }
-                } else {
-                    assertionFailure("The internal thrown error should be a `KingfisherError`.")
-                }
+                assertionFailure("The internal thrown error should be a `KingfisherError`.")
             }
             }
         }
         }
     }
     }
@@ -810,13 +808,10 @@ open class ImageCache {
             do {
             do {
                 let size = try self.diskStorage.totalSize()
                 let size = try self.diskStorage.totalSize()
                 DispatchQueue.main.async { handler(.success(size)) }
                 DispatchQueue.main.async { handler(.success(size)) }
+            } catch let error as KingfisherError {
+                DispatchQueue.main.async { handler(.failure(error)) }
             } catch {
             } catch {
-                if let error = error as? KingfisherError {
-                    DispatchQueue.main.async { handler(.failure(error)) }
-                } else {
-                    assertionFailure("The internal thrown error should be a `KingfisherError`.")
-                }
-                
+                assertionFailure("The internal thrown error should be a `KingfisherError`.")
             }
             }
         }
         }
     }
     }