@@ -4,8 +4,12 @@ extension PlatformLookup {
4
4
/// <#Description#>
5
5
public enum PlatformLookupError : Error , LocalizedError {
6
6
case failedToInitializeDataIsNotValid
7
- case unknowDeviceFamilly( String )
7
+ case invalidIndex( file: String , function: String , line: Int )
8
+ case noResultForThisCombinaison( device: String , runtime: String )
8
9
case noRuntimeFound
10
+ case thisShouldNeverAppen( file: String , function: String , line: Int )
11
+ case unknowDevice( String )
12
+ case unknowRuntime( String )
9
13
/// A localized message describing what error occurred.
10
14
public var errorDescription : String ? {
11
15
switch self {
@@ -14,25 +18,118 @@ extension PlatformLookup {
14
18
" Invalid data at initilisation of `PlatformLookup` " ,
15
19
comment: " Invalid Data "
16
20
)
17
- case . unknowDeviceFamilly( let input) :
18
- return NSLocalizedString ( " Device familly \( input) unknown " , comment: " Unknown Device " )
19
- case . noRuntimeFound: return NSLocalizedString ( " Runtime unknown " , comment: " Unknown Runtime " )
21
+ case . invalidIndex( let file, let function, let line) :
22
+ return NSLocalizedString (
23
+ " Invalid Index at \( function) in \( file) : \( line) " ,
24
+ comment: " Invalid Index "
25
+ )
26
+ case . noResultForThisCombinaison( let device, let runtime) :
27
+ return NSLocalizedString (
28
+ " No result found for device: \( device) , runtime: \( runtime) " ,
29
+ comment: " Invalid device/runtime combinaison "
30
+ )
31
+ case . noRuntimeFound:
32
+ return NSLocalizedString (
33
+ " No runtime found " ,
34
+ comment: " No runtime found "
35
+ )
36
+ case . thisShouldNeverAppen( let file, let function, let line) :
37
+ let message =
38
+ " This should really never happen please look at \( function) in \( file) : \( line) "
39
+ #if DEBUG
40
+ assertionFailure ( message)
41
+ #endif
42
+ return NSLocalizedString ( message, comment: " Unknown Runtime " )
43
+ case . unknowDevice( let device) :
44
+ return NSLocalizedString ( " Unknown \( device) " , comment: " unknown device " )
45
+ case . unknowRuntime( let runtime) :
46
+ return NSLocalizedString (
47
+ " Unknown \( runtime) " ,
48
+ comment: " Unknown runtime "
49
+ )
20
50
}
21
51
}
22
52
/// A localized message describing the reason for the failure.
23
53
public var failureReason : String ? {
24
- return " failureReason " // switch self {
25
- // case .failedToInitializeDataIsNotValid:
26
- // <#code#>
27
- // case .unknowDeviceFamilly(_):
28
- // <#code#>
29
- // case .noRuntimeFound:
30
- // <#code#>
31
- // }
54
+ return " failureReason - need to be implemented "
32
55
}
33
56
/// A localized message describing how one might recover from the failure.
34
- public var recoverySuggestion : String ? { return " failureReason " }
57
+ public var recoverySuggestion : String ? {
58
+ return " recoverySuggestion - need to be implemented "
59
+ }
35
60
/// A localized message providing "help" text if the user requests help.
36
- public var helpAnchor : String ? { return " failureReason " }
61
+ public var helpAnchor : String ? {
62
+ return " helpAnchor - need to be implemented "
63
+ }
64
+ public var invalidIndex : ( file: String , function: String , line: Int ) ? {
65
+ get {
66
+ guard case let . invalidIndex( value) = self else { return nil }
67
+ return value
68
+ }
69
+ set {
70
+ guard case . invalidIndex = self , let newValue = newValue else { return }
71
+ self = . invalidIndex(
72
+ file: newValue. 0 ,
73
+ function: newValue. 1 ,
74
+ line: newValue. 2
75
+ )
76
+ }
77
+ }
78
+ public var noResultForThisCombinaison : ( device: String , runtime: String ) ? {
79
+ get {
80
+ guard case let . noResultForThisCombinaison( value) = self else {
81
+ return nil
82
+ }
83
+ return value
84
+ }
85
+ set {
86
+ guard case . noResultForThisCombinaison = self , let newValue = newValue
87
+ else { return }
88
+ self = . noResultForThisCombinaison(
89
+ device: newValue. 0 ,
90
+ runtime: newValue. 1
91
+ )
92
+ }
93
+ }
94
+ public var thisShouldNeverAppen :
95
+ ( file: String , function: String , line: Int ) ?
96
+ {
97
+ get {
98
+ guard case let . thisShouldNeverAppen( value) = self else { return nil }
99
+ return value
100
+ }
101
+ set {
102
+ guard case . thisShouldNeverAppen = self , let newValue = newValue else {
103
+ return
104
+ }
105
+ self = . thisShouldNeverAppen(
106
+ file: newValue. 0 ,
107
+ function: newValue. 1 ,
108
+ line: newValue. 2
109
+ )
110
+ }
111
+ }
112
+ public var unknowDevice : String ? {
113
+ get {
114
+ guard case let . unknowDevice( value) = self else { return nil }
115
+ return value
116
+ }
117
+ set {
118
+ guard case . unknowDevice = self , let newValue = newValue else { return }
119
+ self = . unknowDevice( newValue)
120
+ }
121
+ }
122
+ public var unknowRuntime : String ? {
123
+ get {
124
+ guard case let . unknowRuntime( value) = self else { return nil }
125
+ return value
126
+ }
127
+ set {
128
+ guard case . unknowRuntime = self , let newValue = newValue else {
129
+ return
130
+ }
131
+ self = . unknowRuntime( newValue)
132
+ }
133
+ }
37
134
}
38
135
}
0 commit comments