AFError

public enum AFError : Error, Sendable
extension AFError: LocalizedError

AFError is the error type returned by Alamofire. It encompasses a few different types of errors, each with their own associated reasons.

Error Booleans

  • Returns whether the instance is .sessionDeinitialized.

    Declaration

    Swift

    public var isSessionDeinitializedError: Bool { get }
  • Returns whether the instance is .sessionInvalidated.

    Declaration

    Swift

    public var isSessionInvalidatedError: Bool { get }
  • Returns whether the instance is .explicitlyCancelled.

    Declaration

    Swift

    public var isExplicitlyCancelledError: Bool { get }
  • Returns whether the instance is .invalidURL.

    Declaration

    Swift

    public var isInvalidURLError: Bool { get }
  • Returns whether the instance is .parameterEncodingFailed. When true, the underlyingError property will contain the associated value.

    Declaration

    Swift

    public var isParameterEncodingError: Bool { get }
  • Returns whether the instance is .parameterEncoderFailed. When true, the underlyingError property will contain the associated value.

    Declaration

    Swift

    public var isParameterEncoderError: Bool { get }
  • Returns whether the instance is .multipartEncodingFailed. When true, the url and underlyingError properties will contain the associated values.

    Declaration

    Swift

    public var isMultipartEncodingError: Bool { get }
  • Returns whether the instance is .requestAdaptationFailed. When true, the underlyingError property will contain the associated value.

    Declaration

    Swift

    public var isRequestAdaptationError: Bool { get }
  • Returns whether the instance is .responseValidationFailed. When true, the acceptableContentTypes, responseContentType, responseCode, and underlyingError properties will contain the associated values.

    Declaration

    Swift

    public var isResponseValidationError: Bool { get }
  • Returns whether the instance is .responseSerializationFailed. When true, the failedStringEncoding and underlyingError properties will contain the associated values.

    Declaration

    Swift

    public var isResponseSerializationError: Bool { get }
  • Returns whether the instance is .serverTrustEvaluationFailed. When true, the underlyingError property will contain the associated value.

    Declaration

    Swift

    public var isServerTrustEvaluationError: Bool { get }
  • Returns whether the instance is requestRetryFailed. When true, the underlyingError property will contain the associated value.

    Declaration

    Swift

    public var isRequestRetryError: Bool { get }
  • Returns whether the instance is createUploadableFailed. When true, the underlyingError property will contain the associated value.

    Declaration

    Swift

    public var isCreateUploadableError: Bool { get }
  • Returns whether the instance is createURLRequestFailed. When true, the underlyingError property will contain the associated value.

    Declaration

    Swift

    public var isCreateURLRequestError: Bool { get }
  • Returns whether the instance is downloadedFileMoveFailed. When true, the destination and underlyingError properties will contain the associated values.

    Declaration

    Swift

    public var isDownloadedFileMoveError: Bool { get }
  • Returns whether the instance is createURLRequestFailed. When true, the underlyingError property will contain the associated value.

    Declaration

    Swift

    public var isSessionTaskError: Bool { get }

Convenience Properties

  • The URLConvertible associated with the error.

    Declaration

    Swift

    public var urlConvertible: (any URLConvertible)? { get }
  • url

    The URL associated with the error.

    Declaration

    Swift

    public var url: URL? { get }
  • The underlying Error responsible for generating the failure associated with .sessionInvalidated, .parameterEncodingFailed, .parameterEncoderFailed, .multipartEncodingFailed, .requestAdaptationFailed, .responseSerializationFailed, .requestRetryFailed errors.

    Declaration

    Swift

    public var underlyingError: (any Error)? { get }
  • The acceptable Content-Types of a .responseValidationFailed error.

    Declaration

    Swift

    public var acceptableContentTypes: [String]? { get }
  • The response Content-Type of a .responseValidationFailed error.

    Declaration

    Swift

    public var responseContentType: String? { get }
  • The response code of a .responseValidationFailed error.

    Declaration

    Swift

    public var responseCode: Int? { get }
  • The String.Encoding associated with a failed .stringResponse() call.

    Declaration

    Swift

    public var failedStringEncoding: String.Encoding? { get }
  • The source URL of a .downloadedFileMoveFailed error.

    Declaration

    Swift

    public var sourceURL: URL? { get }
  • The destination URL of a .downloadedFileMoveFailed error.

    Declaration

    Swift

    public var destinationURL: URL? { get }
  • The download resume data of any underlying network error. Only produced by DownloadRequests.

    Declaration

    Swift

    public var downloadResumeData: Data? { get }

Error Descriptions

  • Declaration

    Swift

    public var errorDescription: String? { get }