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 { ...@@ -49,21 +49,21 @@ extension UdMultiLookupCallback {
if let err = err { if let err = err {
result.errors.append(err as NSError) result.errors.append(err as NSError)
} }
if let contactListJSON = contactListJSON { do {
do { if let data = contactListJSON,
result.contacts = try JSONDecoder() let contactListJSON = try JSONDecoder().decode([Data]?.self, from: data) {
.decode([Data].self, from: contactListJSON) result.contacts = contactListJSON.map { Contact.live($0) }
.map { Contact.live($0) }
} catch {
result.errors.append(error as NSError)
} }
} catch {
result.errors.append(error as NSError)
} }
if let failedIDs = failedIDs { do {
do { if let data = failedIDs,
result.failedIds = try JSONDecoder().decode([Data].self, from: failedIDs) let failedIDs = try JSONDecoder().decode([Data]?.self, from: data) {
} catch { result.failedIds = failedIDs
result.errors.append(error as NSError)
} }
} catch {
result.errors.append(error as NSError)
} }
callback.handle(result) 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