contact update error logging

This commit is contained in:
Iurii Malchenko 2024-03-23 13:03:24 +01:00
parent de4e65ae13
commit 455ad441df
1 changed files with 19 additions and 1 deletions

View File

@ -160,8 +160,26 @@ class ContactTrickManager: NSObject {
saveRequest.update(mutableContact)
do {
try self.contactStore.execute(saveRequest)
} catch let error as NSError {
var details: String?
if error.domain == CNErrorDomain {
switch error.code {
case CNError.authorizationDenied.rawValue:
details = "Authorization denied"
case CNError.communicationError.rawValue:
details = "Communication error"
case CNError.insertedRecordAlreadyExists.rawValue:
details = "Record already exists"
case CNError.dataAccessError.rawValue:
details = "Data access error"
default:
details = "Code \(error.code)"
}
}
trace("in updateContact, failed to update the contact - %{public}@: %{public}@", log: self.log, category: ConstantsLog.categoryContactTrickManager, type: .error, details ?? "no details", error.localizedDescription)
} catch {
trace("in updateContact, failed to update the contact", log: self.log, category: ConstantsLog.categoryContactTrickManager, type: .info)
trace("in updateContact, failed to update the contact: %{public}@", log: self.log, category: ConstantsLog.categoryContactTrickManager, type: .error, error.localizedDescription)
}
}
}