AFError
public enum AFError : Error
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.
- invalidURL: Returned when a
URLConvertibletype fails to create a validURL. - 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.
-
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.
- propertyListEncodingFailed: Property list serialization failed with an underlying system error during encoding process.
Declaration
Swift
public enum ParameterEncodingFailureReason -
The underlying reason the multipart encoding error occurred.
- bodyPartURLInvalid: The
fileURLprovided for reading an encodable body part isn’t a file URL. - bodyPartFilenameInvalid: The filename of the
fileURLprovided has either an emptylastPathComponentor `pathExtension. - bodyPartFileNotReachable: The file at the
fileURLprovided was not reachable. - bodyPartFileNotReachableWithError: Attempting to check the reachability of the
fileURLprovided threw an error. - bodyPartFileIsDirectory: The file at the
fileURLprovided is actually a directory. - bodyPartFileSizeNotAvailable: The size of the file at the
fileURLprovided was not returned by the system. - bodyPartFileSizeQueryFailedWithError: The attempt to find the size of the file at the
fileURLprovided threw an error. - bodyPartInputStreamCreationFailed: An
InputStreamcould not be created for the providedfileURL. - outputStreamCreationFailed: An
OutputStreamcould 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
fileURLprovided 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
InputStreamfailed with underlying system error.
Declaration
Swift
public enum MultipartEncodingFailureReason - bodyPartURLInvalid: The
-
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-Typeand theacceptableContentTypesprovided did not contain wildcard type. - unacceptableContentType: The response
Content-Typedid not match any type in the providedacceptableContentTypes. - unacceptableStatusCode: The response status code was not acceptable.
Declaration
Swift
public enum ResponseValidationFailureReason -
The underlying reason the response serialization error occurred.
- inputDataNil: The server response contained no data.
- inputDataNilOrZeroLength: The server response contained no data or the data was zero length.
- inputFileNil: The file containing the server response did not exist.
- inputFileReadFailed: The file containing the server response could not be read.
- stringSerializationFailed: String serialization failed using the provided
String.Encoding. - jsonSerializationFailed: JSON serialization failed with an underlying system error.
- propertyListSerializationFailed: Property list serialization failed with an underlying system error.
Declaration
Swift
public enum ResponseSerializationFailureReason -
Declaration
Swift
case invalidURL(url: URLConvertible) -
Declaration
Swift
case parameterEncodingFailed(reason: ParameterEncodingFailureReason) -
Declaration
Swift
case multipartEncodingFailed(reason: MultipartEncodingFailureReason) -
Declaration
Swift
case responseValidationFailed(reason: ResponseValidationFailureReason) -
Declaration
Swift
case responseSerializationFailed(reason: ResponseSerializationFailureReason)
-
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, theunderlyingErrorproperty will contain the associated value.Declaration
Swift
public var isParameterEncodingError: Bool { get } -
Returns whether the AFError is a multipart encoding error. When
true, theurlandunderlyingErrorproperties will contain the associated values.Declaration
Swift
public var isMultipartEncodingError: Bool { get } -
Returns whether the
AFErroris a response validation error. Whentrue, theacceptableContentTypes,responseContentType, andresponseCodeproperties will contain the associated values.Declaration
Swift
public var isResponseValidationError: Bool { get } -
Returns whether the
AFErroris a response serialization error. Whentrue, thefailedStringEncodingandunderlyingErrorproperties will contain the associated values.Declaration
Swift
public var isResponseSerializationError: Bool { get }
-
The
URLConvertibleassociated with the error.Declaration
Swift
public var urlConvertible: URLConvertible? { get } -
The
URLassociated with the error.Declaration
Swift
public var url: URL? { get } -
The
Errorreturned by a system framework associated with a.parameterEncodingFailed,.multipartEncodingFailedor.responseSerializationFailederror.Declaration
Swift
public var underlyingError: Error? { get } -
The acceptable
Content-Types of a.responseValidationFailederror.Declaration
Swift
public var acceptableContentTypes: [String]? { get } -
The response
Content-Typeof a.responseValidationFailederror.Declaration
Swift
public var responseContentType: String? { get } -
The response code of a
.responseValidationFailederror.Declaration
Swift
public var responseCode: Int? { get } -
The
String.Encodingassociated with a failed.stringResponse()call.Declaration
Swift
public var failedStringEncoding: String.Encoding? { get }
-
Declaration
Swift
public var errorDescription: String? { get }
AFError Enumeration Reference