forked from Carthage/Carthage
-
Notifications
You must be signed in to change notification settings - Fork 0
/
SwiftVersionError.swift
45 lines (35 loc) · 1.31 KB
/
SwiftVersionError.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import Foundation
internal enum SwiftVersionError: Error {
/// An error in determining the local Swift version
case unknownLocalSwiftVersion
/// An error in determining the framework Swift version
case unknownFrameworkSwiftVersion
/// The framework binary is not compatible with the local Swift version.
case incompatibleFrameworkSwiftVersions(local: String, framework: String)
}
extension SwiftVersionError: CustomStringConvertible {
var description: String {
switch self {
case .unknownLocalSwiftVersion:
return "Unable to determine local Swift version."
case .unknownFrameworkSwiftVersion:
return "Unable to determine framework Swift version."
case let .incompatibleFrameworkSwiftVersions(local, framework):
return "Incompatible Swift version - framework was built with \(framework) and the local version is \(local)."
}
}
}
extension SwiftVersionError: Equatable {
static func == (lhs: SwiftVersionError, rhs: SwiftVersionError) -> Bool {
switch (lhs, rhs) {
case (.unknownLocalSwiftVersion, .unknownLocalSwiftVersion):
return true
case (.unknownFrameworkSwiftVersion, .unknownFrameworkSwiftVersion):
return true
case let (.incompatibleFrameworkSwiftVersions(la, lb), .incompatibleFrameworkSwiftVersions(ra, rb)):
return la == ra && lb == rb
default:
return false
}
}
}