Hello together,
since Xcode Version > 15 the following error handling causes following error "Pattern of type 'DecodingError' cannot match 'Never'
func getSupportedCountries() async {
// fetch all documents from collection "seasons" from firestore
let queryCountries = try? await db.collection("countries").getDocuments()
if queryCountries != nil {
self.countries = (queryCountries!.documents.compactMap({ (queryDocumentSnapshot) -> Country? in
let result = Result { try? queryDocumentSnapshot.data(as: Country.self) }
switch result {
case .success(let country):
if let country = country {
// A country value was successfully initialized from the DocumentSnapshot
self.errorMessage = nil
return country
}
else {
// A nil value was successfully initialized from the DocumentSnapshot,
// or the DocumentSnapshot was nil
self.errorMessage = "Document doesn't exist."
return nil
}
case .failure(let error):
// A Country value could not be initialized from the DocumentSnapshot
switch error {
case DecodingError.typeMismatch(_, let context):
self.errorMessage = "\(error.localizedDescription): \(context.debugDescription)"
case DecodingError.valueNotFound(_, let context):
self.errorMessage = "\(error.localizedDescription): \(context.debugDescription)"
case DecodingError.keyNotFound(_, let context):
self.errorMessage = "\(error.localizedDescription): \(context.debugDescription)"
case DecodingError.dataCorrupted(let key):
self.errorMessage = "\(error.localizedDescription): \(key)"
default:
self.errorMessage = "Error decoding document: \(error.localizedDescription)"
}
return nil
}
}))
} else {
self.errorMessage = "No documents in 'countries' collection"
return
}
}
the interesting part of the code where XCODE shows an error is from "switch error" downwards.
Does anyone of you have an idea what's wrong?
Ay help appreciated !
Thx, Peter