Back to Alamofire

AFError

docs/Enums/AFError.html

5.12.013.4 KB
Original Source

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.

`

                MultipartEncodingFailureReason
                `

The underlying reason the .multipartEncodingFailed error occurred.

See more

Declaration

Swift

public enum MultipartEncodingFailureReason : Sendable

`

                UnexpectedInputStreamLength
                `

Represents unexpected input stream length that occur when encoding the MultipartFormData. Instances will be embedded within an AFError.multipartEncodingFailed .inputStreamReadFailed case.

See more

Declaration

Swift

public struct UnexpectedInputStreamLength : Error

`

                ParameterEncodingFailureReason
                `

The underlying reason the .parameterEncodingFailed error occurred.

See more

Declaration

Swift

public enum ParameterEncodingFailureReason : Sendable

`

                ParameterEncoderFailureReason
                `

The underlying reason the .parameterEncoderFailed error occurred.

See more

Declaration

Swift

public enum ParameterEncoderFailureReason : Sendable

`

                ResponseValidationFailureReason
                `

The underlying reason the .responseValidationFailed error occurred.

See more

Declaration

Swift

public enum ResponseValidationFailureReason : Sendable

`

                ResponseSerializationFailureReason
                `

The underlying reason the response serialization error occurred.

See more

Declaration

Swift

public enum ResponseSerializationFailureReason : Sendable

`

                ServerTrustFailureReason
                `

Underlying reason a server trust evaluation error occurred.

See more

Declaration

Swift

public enum ServerTrustFailureReason : Sendable

`

                URLRequestValidationFailureReason
                `

The underlying reason the .urlRequestValidationFailed error occurred.

See more

Declaration

Swift

public enum URLRequestValidationFailureReason : Sendable

`

                createUploadableFailed(error:)
                `

UploadableConvertible threw an error in createUploadable().

Declaration

Swift

case createUploadableFailed(error: any Error)

`

                createURLRequestFailed(error:)
                `

URLRequestConvertible threw an error in asURLRequest().

Declaration

Swift

case createURLRequestFailed(error: any Error)

`

                downloadedFileMoveFailed(error:source:destination:)
                `

SessionDelegate threw an error while attempting to move downloaded file to destination URL.

Declaration

Swift

case downloadedFileMoveFailed(error: any Error, source: URL, destination: URL)

`

                explicitlyCancelled
                `

Request was explicitly cancelled.

Declaration

Swift

case explicitlyCancelled

`

                invalidURL(url:)
                `

URLConvertible type failed to create a valid URL.

Declaration

Swift

case invalidURL(url: any URLConvertible)

`

                multipartEncodingFailed(reason:)
                `

Multipart form encoding failed.

Declaration

Swift

case multipartEncodingFailed(reason: MultipartEncodingFailureReason)

`

                parameterEncodingFailed(reason:)
                `

ParameterEncoding threw an error during the encoding process.

Declaration

Swift

case parameterEncodingFailed(reason: ParameterEncodingFailureReason)

`

                parameterEncoderFailed(reason:)
                `

ParameterEncoder threw an error while running the encoder.

Declaration

Swift

case parameterEncoderFailed(reason: ParameterEncoderFailureReason)

`

                requestAdaptationFailed(error:)
                `

RequestAdapter threw an error during adaptation.

Declaration

Swift

case requestAdaptationFailed(error: any Error)

`

                requestRetryFailed(retryError:originalError:)
                `

RequestRetrier threw an error during the request retry process.

Declaration

Swift

case requestRetryFailed(retryError: any Error, originalError: any Error)

`

                responseValidationFailed(reason:)
                `

Response validation failed.

Declaration

Swift

case responseValidationFailed(reason: ResponseValidationFailureReason)

`

                responseSerializationFailed(reason:)
                `

Response serialization failed.

Declaration

Swift

case responseSerializationFailed(reason: ResponseSerializationFailureReason)

`

                serverTrustEvaluationFailed(reason:)
                `

ServerTrustEvaluating instance threw an error during trust evaluation.

Declaration

Swift

case serverTrustEvaluationFailed(reason: ServerTrustFailureReason)

`

                sessionDeinitialized
                `

Session which issued the Request was deinitialized, most likely because its reference went out of scope.

Declaration

Swift

case sessionDeinitialized

`

                sessionInvalidated(error:)
                `

Session was explicitly invalidated, possibly with the Error produced by the underlying URLSession.

Declaration

Swift

case sessionInvalidated(error: (any Error)?)

`

                sessionTaskFailed(error:)
                `

URLSessionTask completed with error.

Declaration

Swift

case sessionTaskFailed(error: any Error)

`

                urlRequestValidationFailed(reason:)
                `

URLRequest failed validation.

Declaration

Swift

case urlRequestValidationFailed(reason: URLRequestValidationFailureReason)

Error Booleans

`

                isSessionDeinitializedError
                `

Returns whether the instance is .sessionDeinitialized.

Declaration

Swift

public var isSessionDeinitializedError: Bool { get }

`

                isSessionInvalidatedError
                `

Returns whether the instance is .sessionInvalidated.

Declaration

Swift

public var isSessionInvalidatedError: Bool { get }

`

                isExplicitlyCancelledError
                `

Returns whether the instance is .explicitlyCancelled.

Declaration

Swift

public var isExplicitlyCancelledError: Bool { get }

`

                isInvalidURLError
                `

Returns whether the instance is .invalidURL.

Declaration

Swift

public var isInvalidURLError: Bool { get }

`

                isParameterEncodingError
                `

Returns whether the instance is .parameterEncodingFailed. When true, the underlyingError property will contain the associated value.

Declaration

Swift

public var isParameterEncodingError: Bool { get }

`

                isParameterEncoderError
                `

Returns whether the instance is .parameterEncoderFailed. When true, the underlyingError property will contain the associated value.

Declaration

Swift

public var isParameterEncoderError: Bool { get }

`

                isMultipartEncodingError
                `

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 }

`

                isRequestAdaptationError
                `

Returns whether the instance is .requestAdaptationFailed. When true, the underlyingError property will contain the associated value.

Declaration

Swift

public var isRequestAdaptationError: Bool { get }

`

                isResponseValidationError
                `

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 }

`

                isResponseSerializationError
                `

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 }

`

                isServerTrustEvaluationError
                `

Returns whether the instance is .serverTrustEvaluationFailed. When true, the underlyingError property will contain the associated value.

Declaration

Swift

public var isServerTrustEvaluationError: Bool { get }

`

                isRequestRetryError
                `

Returns whether the instance is requestRetryFailed. When true, the underlyingError property will contain the associated value.

Declaration

Swift

public var isRequestRetryError: Bool { get }

`

                isCreateUploadableError
                `

Returns whether the instance is createUploadableFailed. When true, the underlyingError property will contain the associated value.

Declaration

Swift

public var isCreateUploadableError: Bool { get }

`

                isCreateURLRequestError
                `

Returns whether the instance is createURLRequestFailed. When true, the underlyingError property will contain the associated value.

Declaration

Swift

public var isCreateURLRequestError: Bool { get }

`

                isDownloadedFileMoveError
                `

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 }

`

                isSessionTaskError
                `

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

`

                urlConvertible
                `

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 }

`

                underlyingError
                `

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 }

`

                acceptableContentTypes
                `

The acceptable Content-Types of a .responseValidationFailed error.

Declaration

Swift

public var acceptableContentTypes: [String]? { get }

`

                responseContentType
                `

The response Content-Type of a .responseValidationFailed error.

Declaration

Swift

public var responseContentType: String? { get }

`

                responseCode
                `

The response code of a .responseValidationFailed error.

Declaration

Swift

public var responseCode: Int? { get }

`

                failedStringEncoding
                `

The String.Encoding associated with a failed .stringResponse() call.

Declaration

Swift

public var failedStringEncoding: String.Encoding? { get }

`

                sourceURL
                `

The source URL of a .downloadedFileMoveFailed error.

Declaration

Swift

public var sourceURL: URL? { get }

`

                destinationURL
                `

The destination URL of a .downloadedFileMoveFailed error.

Declaration

Swift

public var destinationURL: URL? { get }

`

                downloadResumeData
                `

The download resume data of any underlying network error. Only produced by DownloadRequests.

Declaration

Swift

public var downloadResumeData: Data? { get }

Error Descriptions

`

                errorDescription
                `

Declaration

Swift

public var errorDescription: String? { get }