@@ -120,121 +120,225 @@ extension Error: LocalizedError {
120120 public var errorDescription : String ? {
121121 switch self {
122122 case . nullDistribution, . noSuchFilePrefix, . noSuchFile:
123+ #if canImport(Darwin)
123124 return String ( localized: " Couldn’t load distribution. " , comment: " error description " )
125+ #else
126+ return " Couldn’t load distribution. "
127+ #endif
124128 case . badResponse, . noData, . downloadFailed:
129+ #if canImport(Darwin)
125130 return String ( localized: " Couldn’t download distribution. " , comment: " error description " )
131+ #else
132+ return " Couldn’t download distribution. "
133+ #endif
126134 case . unknownARTCC, . unknownARTCCFrequency, . unknownFieldId,
127135 . unknownFrequencyFieldId, . invalidFrequency, . unknownFSS,
128136 . invalidRunwaySurface, . invalidPavementClassification,
129137 . invalidVGSI, . unknownNavaid, . invalidAltitudeFormat:
138+ #if canImport(Darwin)
130139 return String ( localized: " Couldn’t parse distribution data. " , comment: " error description " )
140+ #else
141+ return " Couldn’t parse distribution data. "
142+ #endif
131143 case . notYetLoaded:
144+ #if canImport(Darwin)
132145 return String ( localized: " This NASR has not been loaded yet. " , comment: " error description " )
146+ #else
147+ return " This NASR has not been loaded yet. "
148+ #endif
133149 }
134150 }
135151
136152 public var failureReason : String ? {
137153 switch self {
138154 case . nullDistribution:
155+ #if canImport(Darwin)
139156 return String (
140157 localized: " Called .load() on a null distribution. " ,
141158 comment: " failure reason "
142159 )
160+ #else
161+ return " Called .load() on a null distribution. "
162+ #endif
143163 case . badResponse( let response) :
164+ #if canImport(Darwin)
144165 return String (
145166 localized: " Bad response: \( response. description) . " ,
146167 comment: " failure reason "
147168 )
169+ #else
170+ return " Bad response: \( response. description) . "
171+ #endif
148172 case . downloadFailed( let reason) :
173+ #if canImport(Darwin)
149174 return String ( localized: " Download failed: \( reason) " , comment: " failure reason " )
175+ #else
176+ return " Download failed: \( reason) "
177+ #endif
150178 case . noSuchFilePrefix( let prefix) :
179+ #if canImport(Darwin)
151180 return String (
152181 localized: " Couldn’t find file in archive with prefix ‘ \( prefix) .’ " ,
153182 comment: " failure reason "
154183 )
184+ #else
185+ return " Couldn’t find file in archive with prefix ‘ \( prefix) .’ "
186+ #endif
155187 case . noData:
188+ #if canImport(Darwin)
156189 return String ( localized: " No data was downloaded. " , comment: " failure reason " )
190+ #else
191+ return " No data was downloaded. "
192+ #endif
157193 case . unknownARTCC( let ID) :
194+ #if canImport(Darwin)
158195 return String (
159196 localized: " Referenced undefined ARTCC record with ID ‘ \( ID) ’. " ,
160197 comment: " failure reason "
161198 )
199+ #else
200+ return " Referenced undefined ARTCC record with ID ‘ \( ID) ’. "
201+ #endif
162202 case let . unknownARTCCFrequency( frequency, ARTCC) :
203+ #if canImport(Darwin)
163204 return String (
164205 localized: " Referenced undefined frequency ‘ \( frequency) ’ for ARTCC \( ARTCC . code) . " ,
165206 comment: " failure reason "
166207 )
208+ #else
209+ return " Referenced undefined frequency ‘ \( frequency) ’ for ARTCC \( ARTCC . code) . "
210+ #endif
167211 case let . unknownFieldId( fieldId, ARTCC) :
212+ #if canImport(Darwin)
168213 return String (
169214 localized: " Unknown field ID ‘ \( fieldId) ’ at ‘ \( ARTCC . code) \( ARTCC . locationName) ’. " ,
170215 comment: " failure reason "
171216 )
217+ #else
218+ return " Unknown field ID ‘ \( fieldId) ’ at ‘ \( ARTCC . code) \( ARTCC . locationName) ’. "
219+ #endif
172220 case let . unknownFrequencyFieldId( fieldId, frequency, ARTCC) :
221+ #if canImport(Darwin)
173222 return String (
174223 localized:
175224 " Unknown field ID ' \( fieldId) ' for \( frequency. frequencyKHz) kHz at ' \( ARTCC . code) \( ARTCC . locationName) '. " ,
176225 comment: " failure reason "
177226 )
227+ #else
228+ return " Unknown field ID ' \( fieldId) ' for \( frequency. frequencyKHz) kHz at ' \( ARTCC . code) \( ARTCC . locationName) '. "
229+ #endif
178230 case . invalidFrequency( let string) :
231+ #if canImport(Darwin)
179232 return String ( localized: " Invalid frequency ‘ \( string) ’. " , comment: " failure reason " )
233+ #else
234+ return " Invalid frequency ‘ \( string) ’. "
235+ #endif
180236 case . unknownFSS( let ID) :
237+ #if canImport(Darwin)
181238 return String (
182239 localized: " Continuation record references unknown FSS ‘ \( ID) ’. " ,
183240 comment: " failure reason "
184241 )
242+ #else
243+ return " Continuation record references unknown FSS ‘ \( ID) ’. "
244+ #endif
185245 case . notYetLoaded:
246+ #if canImport(Darwin)
186247 return String (
187248 localized: " Attempted to access NASR data before .load() was called. " ,
188249 comment: " failure reason "
189250 )
251+ #else
252+ return " Attempted to access NASR data before .load() was called. "
253+ #endif
190254 case . noSuchFile( let path) :
255+ #if canImport(Darwin)
191256 return String (
192257 localized: " No such file in distribution: \( path) . " ,
193258 comment: " failure reason "
194259 )
260+ #else
261+ return " No such file in distribution: \( path) . "
262+ #endif
195263 case . invalidRunwaySurface( let string) :
264+ #if canImport(Darwin)
196265 return String ( localized: " Unknown runway surface ‘ \( string) ’. " , comment: " failure reason " )
266+ #else
267+ return " Unknown runway surface ‘ \( string) ’. "
268+ #endif
197269 case . invalidPavementClassification( let string) :
270+ #if canImport(Darwin)
198271 return String (
199272 localized: " Unknown pavement classification ‘ \( string) ’ for PCN. " ,
200273 comment: " failure reason "
201274 )
275+ #else
276+ return " Unknown pavement classification ‘ \( string) ’ for PCN. "
277+ #endif
202278 case . invalidVGSI( let string) :
279+ #if canImport(Darwin)
203280 return String ( localized: " Unknown VGSI identifier ‘ \( string) ’. " , comment: " failure reason " )
281+ #else
282+ return " Unknown VGSI identifier ‘ \( string) ’. "
283+ #endif
204284 case . unknownNavaid( let string) :
285+ #if canImport(Darwin)
205286 return String ( localized: " Unknown navaid ‘ \( string) ’. " , comment: " failure reason " )
287+ #else
288+ return " Unknown navaid ‘ \( string) ’. "
289+ #endif
206290 case . invalidAltitudeFormat( let string) :
291+ #if canImport(Darwin)
207292 return String ( localized: " Invalid altitude format ‘ \( string) ’. " , comment: " failure reason " )
293+ #else
294+ return " Invalid altitude format ‘ \( string) ’. "
295+ #endif
208296 }
209297 }
210298
211299 public var recoverySuggestion : String ? {
212300 switch self {
213301 case . nullDistribution:
302+ #if canImport(Darwin)
214303 return String (
215304 localized:
216305 " Do not call .load() on a NullDistribution. Use NullDistribution for distributions that were previously loaded and serialized to disk. " ,
217306 comment: " recovery suggestion "
218307 )
308+ #else
309+ return " Do not call .load() on a NullDistribution. Use NullDistribution for distributions that were previously loaded and serialized to disk. "
310+ #endif
219311 case . badResponse, . noData, . downloadFailed:
312+ #if canImport(Darwin)
220313 return String (
221314 localized: " Verify that the URL to the distribution is correct and accessible. " ,
222315 comment: " recovery suggestion "
223316 )
317+ #else
318+ return " Verify that the URL to the distribution is correct and accessible. "
319+ #endif
224320 case . unknownARTCC, . unknownARTCCFrequency, . unknownFieldId,
225321 . unknownFrequencyFieldId, . invalidFrequency, . unknownFSS,
226322 . invalidRunwaySurface, . invalidPavementClassification,
227323 . invalidVGSI, . unknownNavaid, . noSuchFilePrefix, . noSuchFile,
228324 . invalidAltitudeFormat:
325+ #if canImport(Darwin)
229326 return String (
230327 localized: " The NASR FADDS format may have changed, requiring an update to SwiftNASR. " ,
231328 comment: " recovery suggestion "
232329 )
330+ #else
331+ return " The NASR FADDS format may have changed, requiring an update to SwiftNASR. "
332+ #endif
233333 case . notYetLoaded:
334+ #if canImport(Darwin)
234335 return String (
235336 localized: " Call .load() before accessing NASR data. " ,
236337 comment: " recovery suggestion "
237338 )
339+ #else
340+ return " Call .load() before accessing NASR data. "
341+ #endif
238342 }
239343 }
240344}
0 commit comments