Skip to content
Snippets Groups Projects
Commit 62c8a894 authored by Dariusz Rybicki's avatar Dariusz Rybicki
Browse files

Update UdMultiLookupCallback

Improve error handling
parent 6e220b88
No related branches found
No related tags found
2 merge requests!112Restore contacts from backup,!102Release 1.0.0
This commit is part of merge request !112. Comments created here will be created in the context of that merge request.
......@@ -49,21 +49,21 @@ extension UdMultiLookupCallback {
if let err = err {
result.errors.append(err as NSError)
}
if let contactListJSON = contactListJSON {
do {
result.contacts = try JSONDecoder()
.decode([Data].self, from: contactListJSON)
.map { Contact.live($0) }
} catch {
result.errors.append(error as NSError)
do {
if let data = contactListJSON,
let contactListJSON = try JSONDecoder().decode([Data]?.self, from: data) {
result.contacts = contactListJSON.map { Contact.live($0) }
}
} catch {
result.errors.append(error as NSError)
}
if let failedIDs = failedIDs {
do {
result.failedIds = try JSONDecoder().decode([Data].self, from: failedIDs)
} catch {
result.errors.append(error as NSError)
do {
if let data = failedIDs,
let failedIDs = try JSONDecoder().decode([Data]?.self, from: data) {
result.failedIds = failedIDs
}
} catch {
result.errors.append(error as NSError)
}
callback.handle(result)
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment