KingfisherError

public enum KingfisherError : Error
extension KingfisherError: LocalizedError
extension KingfisherError: CustomNSError

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.

Error Reason Types

  • Represents the error reason during networking request phase.

    • emptyRequest: The request is empty. Code 1001.
    • invalidURL: The URL of request is invalid. Code 1002.
    • taskCancelled: The downloading task is cancelled by user. Code 1003.
    See more

    Declaration

    Swift

    public enum RequestErrorReason
  • Represents the error reason during networking response phase.

    • invalidURLResponse: The response is not a valid URL response. Code 2001.
    • invalidHTTPStatusCode: The response contains an invalid HTTP status code. Code 2002.
    • URLSessionError: An error happens in the system URL session. Code 2003.
    • dataModifyingFailed: Data modifying fails on returning a valid data. Code 2004.
    • noURLResponse: The task is done but no URL response found. Code 2005.
    See more

    Declaration

    Swift

    public enum ResponseErrorReason
  • 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.
    See more

    Declaration

    Swift

    public enum CacheErrorReason
  • Represents the error reason during image processing phase.

    • processingFailed: Image processing fails. There is no valid output image from the processor. Code 4001.
    See more

    Declaration

    Swift

    public enum ProcessorErrorReason
  • Represents the error reason during image setting in a view related class.

    • emptySource: The input resource is empty or nil. Code 5001.
    • notCurrentSourceTask: The source task is finished, but it is not the one expected now. Code 5002.
    • dataProviderError: An error happens during getting data from an ImageDataProvider. Code 5003.
    See more

    Declaration

    Swift

    public enum ImageSettingErrorReason

Member Cases

Helper Properties & Methods

  • Helper property to check whether this error is a RequestErrorReason.taskCancelled or not.

    Declaration

    Swift

    public var isTaskCancelled: Bool { get }
  • Helper method to check whether this error is a ResponseErrorReason.invalidHTTPStatusCode and the associated value is a given status code.

    Declaration

    Swift

    public func isInvalidResponseStatusCode(_ code: Int) -> Bool

    Parameters

    code

    The given status code.

    Return Value

    If self is a ResponseErrorReason.invalidHTTPStatusCode error and its status code equals to code, true is returned. Otherwise, false.

  • Undocumented

    Declaration

    Swift

    public var isInvalidResponseStatusCode: Bool { get }
  • Helper property to check whether this error is a ImageSettingErrorReason.notCurrentSourceTask or not. When a new image setting task starts while the old one is still running, the new task identifier will be set and the old one is overwritten. A .notCurrentSourceTask error will be raised when the old task finishes to let you know the setting process finishes with a certain result, but the image view or button is not set.

    Declaration

    Swift

    public var isNotCurrentTask: Bool { get }

LocalizedError Conforming

CustomNSError Conforming

  • The error domain of KingfisherError. All errors from Kingfisher is under this domain.

    Declaration

    Swift

    public static let domain: String
  • The error code within the given domain.

    Declaration

    Swift

    public var errorCode: Int { get }