Kingfisher Documentation

Enumeration Kingfisher​Error.​Cache​Error​Reason

public enum CacheErrorReason  

Represents the error reason during Kingfisher caching system.

  • fileEnumeratorCreationFailed: Cannot create a file enumerator for a certain disk URL. Code 3001.

  • invalidFileEnumeratorContent: Cannot get correct file contents from a file enumerator. Code 3002.

  • invalidURLResource: The file at target URL exists, but its URL resource is unavailable. Code 3003.

  • cannotLoadDataFromDisk: The file at target URL exists, but the data cannot be loaded from it. Code 3004.

  • cannotCreateDirectory: Cannot create a folder at a given path. Code 3005.

  • 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.

Member Of

KingfisherError

Represents all the errors which can happen in Kingfisher framework. Kingfisher related methods always throw a KingfisherError or invoke the callback with KingfisherError as its error type. To handle errors from Kingfisher, you switch over the error to get a reason catalog, then switch over the reason to know error detail.

Enumeration Cases

file​Enumerator​Creation​Failed

case fileEnumeratorCreationFailed(url: URL) 

Cannot create a file enumerator for a certain disk URL. Code 3001.

  • url: The target disk URL from which the file enumerator should be created.

invalid​File​Enumerator​Content

case invalidFileEnumeratorContent(url: URL) 

Cannot get correct file contents from a file enumerator. Code 3002.

  • url: The target disk URL from which the content of a file enumerator should be got.

invalid​URLResource

case invalidURLResource(error: Error, key: String, url: URL) 

The file at target URL exists, but its URL resource is unavailable. Code 3003.

  • error: The underlying error thrown by file manager.

  • key: The key used to getting the resource from cache.

  • url: The disk URL where the target cached file exists.

cannot​Load​Data​From​Disk

case cannotLoadDataFromDisk(url: URL, error: Error) 

The file at target URL exists, but the data cannot be loaded from it. Code 3004.

  • url: The disk URL where the target cached file exists.

  • error: The underlying error which describes why this error happens.

cannot​Create​Directory

case cannotCreateDirectory(path: String, error: Error) 

Cannot create a folder at a given path. Code 3005.

  • path: The disk path where the directory creating operation fails.

  • error: The underlying error which describes why this error happens.

image​Not​Existing

case imageNotExisting(key: String) 

The requested image does not exist in cache. Code 3006.

  • key: Key of the requested image in cache.

cannot​Convert​ToData

case cannotConvertToData(object: Any, error: Error) 

Cannot convert an object to data for storing. Code 3007.

  • object: The object which needs be convert to data.

cannot​Serialize​Image

case cannotSerializeImage(image: KFCrossPlatformImage?, original: Data?, serializer: CacheSerializer) 

Cannot serialize an image to data for storing. Code 3008.

  • image: The input image needs to be serialized to cache.

  • original: The original image data, if exists.

  • serializer: The CacheSerializer used for the image serializing.

cannot​Create​Cache​File

case cannotCreateCacheFile(fileURL: URL, key: String, data: Data, error: Error) 

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.

cannot​Set​Cache​File​Attribute

case cannotSetCacheFileAttribute(filePath: String, attributes: [FileAttributeKey : Any], 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.

disk​Storage​IsNot​Ready

case diskStorageIsNotReady(cacheURL: URL) 

The disk storage of cache is not ready. Code 3011.

This is usually due to extremely lack of space on disk storage, and Kingfisher failed even when creating the cache folder. The disk storage will be in unusable state. Normally, ask user to free some spaces and restart the app to make the disk storage work again.

  • cacheURL: The intended URL which should be the storage folder.