|
|
@@ -100,6 +100,8 @@ public enum KingfisherError: Error {
|
|
|
/// - imageNotExisting: The requested image does not exist in cache. Code 3006.
|
|
|
/// - cannotConvertToData: Cannot convert an object to data for storing. Code 3007.
|
|
|
/// - cannotSerializeImage: Cannot serialize an image to data for storing. Code 3008.
|
|
|
+ /// - cannotCreateCacheFile: Cannot create the cache file at a certain fileURL under a key. Code 3009.
|
|
|
+ /// - cannotSetCacheFileAttribute: Cannot set file attributes to a cached file. Code 3010.
|
|
|
public enum CacheErrorReason {
|
|
|
|
|
|
/// Cannot create a file enumerator for a certain disk URL. Code 3001.
|
|
|
@@ -139,6 +141,22 @@ public enum KingfisherError: Error {
|
|
|
/// - original: The original image data, if exists.
|
|
|
/// - serializer: The `CacheSerializer` used for the image serializing.
|
|
|
case cannotSerializeImage(image: KFCrossPlatformImage?, original: Data?, serializer: CacheSerializer)
|
|
|
+
|
|
|
+ /// Cannot create the cache file at a certain fileURL under a key. Code 3009.
|
|
|
+ /// - fileURL: The url where the cache file should be created.
|
|
|
+ /// - key: The cache key used for the cache. When caching a file through `KingfisherManager` and Kingfisher's
|
|
|
+ /// extension method, it is the resolved cache key based on your input `Source` and the image processors.
|
|
|
+ /// - data: The data to be cached.
|
|
|
+ /// - error: The underlying error originally thrown by Foundation when writing the `data` to the disk file at
|
|
|
+ /// `fileURL`.
|
|
|
+ case cannotCreateCacheFile(fileURL: URL, key: String, data: Data, error: Error)
|
|
|
+
|
|
|
+ /// Cannot set file attributes to a cached file. Code 3010.
|
|
|
+ /// - filePath: The path of target cache file.
|
|
|
+ /// - attributes: The file attribute to be set to the target file.
|
|
|
+ /// - error: The underlying error originally thrown by Foundation when setting the `attributes` to the disk
|
|
|
+ /// file at `filePath`.
|
|
|
+ case cannotSetCacheFileAttribute(filePath: String, attributes: [FileAttributeKey : Any], error: Error)
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -346,6 +364,12 @@ extension KingfisherError.CacheErrorReason {
|
|
|
return "Cannot serialize an image due to the cache serializer returning `nil`. " +
|
|
|
"Image: \(String(describing:image)), original data: \(String(describing: originalData)), " +
|
|
|
"serializer: \(serializer)."
|
|
|
+ case .cannotCreateCacheFile(let fileURL, let key, let data, let error):
|
|
|
+ return "Cannot create cache file at url: \(fileURL), key: \(key), data length: \(data.count). " +
|
|
|
+ "Underlying foundation error: \(error)."
|
|
|
+ case .cannotSetCacheFileAttribute(let filePath, let attributes, let error):
|
|
|
+ return "Cannot set file attribute for the cache file at path: \(filePath), attributes: \(attributes)." +
|
|
|
+ "Underlying foundation error: \(error)."
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -359,6 +383,8 @@ extension KingfisherError.CacheErrorReason {
|
|
|
case .imageNotExisting: return 3006
|
|
|
case .cannotConvertToData: return 3007
|
|
|
case .cannotSerializeImage: return 3008
|
|
|
+ case .cannotCreateCacheFile: return 3009
|
|
|
+ case .cannotSetCacheFileAttribute: return 3010
|
|
|
}
|
|
|
}
|
|
|
}
|