|
|
@@ -24,6 +24,10 @@
|
|
|
|
|
|
import Foundation
|
|
|
|
|
|
+#if canImport(Security)
|
|
|
+import Security
|
|
|
+#endif
|
|
|
+
|
|
|
/// `AFError` is the error type returned by Alamofire. It encompasses a few different types of errors, each with
|
|
|
/// their own associated reasons.
|
|
|
public enum AFError: Error {
|
|
|
@@ -129,7 +133,7 @@ public enum AFError: Error {
|
|
|
case invalidEmptyResponse(type: String)
|
|
|
}
|
|
|
|
|
|
- #if !(os(Linux) || os(Windows))
|
|
|
+ #if canImport(Security)
|
|
|
/// Underlying reason a server trust evaluation error occurred.
|
|
|
public enum ServerTrustFailureReason {
|
|
|
/// The output of a server trust evaluation.
|
|
|
@@ -211,7 +215,7 @@ public enum AFError: Error {
|
|
|
case responseValidationFailed(reason: ResponseValidationFailureReason)
|
|
|
/// Response serialization failed.
|
|
|
case responseSerializationFailed(reason: ResponseSerializationFailureReason)
|
|
|
- #if !(os(Linux) || os(Windows))
|
|
|
+ #if canImport(Security)
|
|
|
/// `ServerTrustEvaluating` instance threw an error during trust evaluation.
|
|
|
case serverTrustEvaluationFailed(reason: ServerTrustFailureReason)
|
|
|
#endif
|
|
|
@@ -314,7 +318,7 @@ extension AFError {
|
|
|
return false
|
|
|
}
|
|
|
|
|
|
- #if !(os(Linux) || os(Windows))
|
|
|
+ #if canImport(Security)
|
|
|
/// Returns whether the instance is `.serverTrustEvaluationFailed`. When `true`, the `underlyingError` property will
|
|
|
/// contain the associated value.
|
|
|
public var isServerTrustEvaluationError: Bool {
|
|
|
@@ -393,7 +397,7 @@ extension AFError {
|
|
|
return reason.underlyingError
|
|
|
case let .responseSerializationFailed(reason):
|
|
|
return reason.underlyingError
|
|
|
- #if !(os(Linux) || os(Windows))
|
|
|
+ #if canImport(Security)
|
|
|
case let .serverTrustEvaluationFailed(reason):
|
|
|
return reason.underlyingError
|
|
|
#endif
|
|
|
@@ -451,7 +455,7 @@ extension AFError {
|
|
|
return destination
|
|
|
}
|
|
|
|
|
|
- #if !(os(Linux) || os(Windows))
|
|
|
+ #if canImport(Security)
|
|
|
/// The download resume data of any underlying network error. Only produced by `DownloadRequest`s.
|
|
|
public var downloadResumeData: Data? {
|
|
|
(underlyingError as? URLError)?.userInfo[NSURLSessionDownloadTaskResumeData] as? Data
|
|
|
@@ -610,7 +614,7 @@ extension AFError.ResponseSerializationFailureReason {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-#if !(os(Linux) || os(Windows))
|
|
|
+#if canImport(Security)
|
|
|
extension AFError.ServerTrustFailureReason {
|
|
|
var output: AFError.ServerTrustFailureReason.Output? {
|
|
|
switch self {
|
|
|
@@ -688,7 +692,7 @@ extension AFError: LocalizedError {
|
|
|
"""
|
|
|
case let .sessionInvalidated(error):
|
|
|
return "Session was invalidated with error: \(error?.localizedDescription ?? "No description.")"
|
|
|
- #if !(os(Linux) || os(Windows))
|
|
|
+ #if canImport(Security)
|
|
|
case let .serverTrustEvaluationFailed(reason):
|
|
|
return "Server trust evaluation failed due to reason: \(reason.localizedDescription)"
|
|
|
#endif
|
|
|
@@ -822,7 +826,7 @@ extension AFError.ResponseValidationFailureReason {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-#if !(os(Linux) || os(Windows))
|
|
|
+#if canImport(Security)
|
|
|
extension AFError.ServerTrustFailureReason {
|
|
|
var localizedDescription: String {
|
|
|
switch self {
|