As you can see, I have a very complicated function:
func save(records: [CKRecord], recordIDsToDelete: [CKRecord.ID], handler: CountHandler?, completion: RequestsHandler?) {}
That function I will rewrite to async-await in the future. But for now, I need to inject it into the current code. How can I do it to make it work?
private func save(records: [CKRecord], handler: ProgressHandler?) throws -> Bool {
save(records: records, recordIDsToDelete: []) { count in
handler?("Saving\n\(count)\nrecords.")
} completion: { _, _, _, error in
guard let error = error else {
return true
return
}
throw error
}
}
What do I need to have? I need to know if there was a success or failure, and if failure, I need to know the error.