Alamofire源码导读五:错误表示

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

使用 AFError 来表示所有的网络错误,分为几大类,每一类又分几小类。
AFError 是一个枚举类型!下面就是所有的枚举值。

case invalidURL(url: URLConvertible)
case parameterEncodingFailed(reason: ParameterEncodingFailureReason)
case multipartEncodingFailed(reason: MultipartEncodingFailureReason)
case responseValidationFailed(reason: ResponseValidationFailureReason)
case responseSerializationFailed(reason: ResponseSerializationFailureReason)

每一个枚举值,都有对应的关联值,关联值又是枚举,有的还带有参数。
这样子就把所有的错误都分类完成了。

上图中,有红色边框的,可以获取到Error 类型。
绿色文字的,可以获取到 URL 信息。

错误信息

猜你喜欢

转载自www.cnblogs.com/huahuahu/p/Alamofire-yuan-ma-dao-du-wu-cuo-wu-biao-shi.html