AFError

public enum AFError : Error

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

  • explicitlyCancelled: Returned when a Request is explicitly cancelled.
  • invalidURL: Returned when a URLConvertible type fails to create a valid URL.
  • parameterEncodingFailed: Returned when a parameter encoding object throws an error during the encoding process.
  • multipartEncodingFailed: Returned when some step in the multipart encoding process fails.
  • responseValidationFailed: Returned when a validate() call fails.
  • responseSerializationFailed: Returned when a response serializer encounters an error in the serialization process.
  • certificatePinningFailed: Returned when a response fails certificate pinning.
  • The underlying reason the parameter encoding error occurred.

    • missingURL: The URL request did not have a URL to encode.
    • jsonEncodingFailed: JSON serialization failed with an underlying system error during the encoding process.
    See more

    Declaration

    Swift

    public enum ParameterEncodingFailureReason
  • Underlying reason the parameter encoder error occured.

    See more

    Declaration

    Swift

    public enum ParameterEncoderFailureReason
  • The underlying reason the multipart encoding error occurred.

    • bodyPartURLInvalid: The fileURL provided for reading an encodable body part isn’t a file URL.
    • bodyPartFilenameInvalid: The filename of the fileURL provided has either an empty lastPathComponent or `pathExtension.
    • bodyPartFileNotReachable: The file at the fileURL provided was not reachable.
    • bodyPartFileNotReachableWithError: Attempting to check the reachability of the fileURL provided threw an error.
    • bodyPartFileIsDirectory: The file at the fileURL provided is actually a directory.
    • bodyPartFileSizeNotAvailable: The size of the file at the fileURL provided was not returned by the system.
    • bodyPartFileSizeQueryFailedWithError: The attempt to find the size of the file at the fileURL provided threw an error.
    • bodyPartInputStreamCreationFailed: An InputStream could not be created for the provided fileURL.
    • outputStreamCreationFailed: An OutputStream could not be created when attempting to write the encoded data to disk.
    • outputStreamFileAlreadyExists: The encoded body data could not be writtent disk because a file already exists at the provided fileURL.
    • outputStreamURLInvalid: The fileURL provided for writing the encoded body data to disk is not a file URL.
    • outputStreamWriteFailed: The attempt to write the encoded body data to disk failed with an underlying error.
    • inputStreamReadFailed: The attempt to read an encoded body part InputStream failed with underlying system error.
    See more

    Declaration

    Swift

    public enum MultipartEncodingFailureReason
  • The underlying reason the response validation error occurred.

    • dataFileNil: The data file containing the server response did not exist.
    • dataFileReadFailed: The data file containing the server response could not be read.
    • missingContentType: The response did not contain a Content-Type and the acceptableContentTypes provided did not contain wildcard type.
    • unacceptableContentType: The response Content-Type did not match any type in the provided acceptableContentTypes.
    • unacceptableStatusCode: The response status code was not acceptable.
    See more

    Declaration

    Swift

    public enum ResponseValidationFailureReason
  • The underlying reason the response serialization error occurred.

    See more

    Declaration

    Swift

    public enum ResponseSerializationFailureReason
  • Underlying reason a server trust evaluation error occured.

    See more

    Declaration

    Swift

    public enum ServerTrustFailureReason
  • Undocumented

    Declaration

    Swift

    case explicitlyCancelled
  • Undocumented

    Declaration

    Swift

    case invalidURL(url: URLConvertible)
  • Undocumented

    Declaration

    Swift

    case parameterEncodingFailed(reason: ParameterEncodingFailureReason)
  • Undocumented

    Declaration

    Swift

    case parameterEncoderFailed(reason: ParameterEncoderFailureReason)
  • Undocumented

    Declaration

    Swift

    case multipartEncodingFailed(reason: MultipartEncodingFailureReason)
  • Undocumented

    Declaration

    Swift

    case responseValidationFailed(reason: ResponseValidationFailureReason)
  • Undocumented

    Declaration

    Swift

    case responseSerializationFailed(reason: ResponseSerializationFailureReason)
  • Undocumented

    Declaration

    Swift

    case serverTrustEvaluationFailed(reason: ServerTrustFailureReason)
  • Returns whether the AFError is an explicitly cancelled error.

    Declaration

    Swift

    public var isExplicitlyCancelledError: Bool { get }
  • Returns whether the AFError is an invalid URL error.

    Declaration

    Swift

    public var isInvalidURLError: Bool { get }
  • Returns whether the AFError is a parameter encoding error. When true, the underlyingError property will contain the associated value.

    Declaration

    Swift

    public var isParameterEncodingError: Bool { get }
  • Returns whether the instance is a parameter encoder error.

    Declaration

    Swift

    public var isParameterEncoderError: Bool { get }
  • Returns whether the AFError is a multipart encoding error. When true, the url and underlyingError properties will contain the associated values.

    Declaration

    Swift

    public var isMultipartEncodingError: Bool { get }
  • Returns whether the AFError is a response validation error. When true, the acceptableContentTypes, responseContentType, and responseCode properties will contain the associated values.

    Declaration

    Swift

    public var isResponseValidationError: Bool { get }
  • Returns whether the AFError is a response serialization error. When true, the failedStringEncoding and underlyingError properties will contain the associated values.

    Declaration

    Swift

    public var isResponseSerializationError: Bool { get }
  • Returns whether the AFError is a server trust evaluation error.

    Declaration

    Swift

    public var isServerTrustEvaluationError: Bool { get }
  • The URLConvertible associated with the error.

    Declaration

    Swift

    public var urlConvertible: URLConvertible? { get }
  • url

    The URL associated with the error.

    Declaration

    Swift

    public var url: URL? { get }
  • The Error returned by a system framework associated with a .parameterEncodingFailed, .parameterEncoderFailed, .multipartEncodingFailed or .responseSerializationFailed error.

    Declaration

    Swift

    public var underlyingError: 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 }
  • Declaration

    Swift

    public var errorDescription: String? { get }