Showing
1 changed file
with
18 additions
and
7 deletions
... | @@ -2388,7 +2388,8 @@ public final class WarplySDK { | ... | @@ -2388,7 +2388,8 @@ public final class WarplySDK { |
2388 | uuid: String = "", | 2388 | uuid: String = "", |
2389 | distance: Int = 0, | 2389 | distance: Int = 0, |
2390 | parentUuids: [String] = [], | 2390 | parentUuids: [String] = [], |
2391 | - completion: @escaping ([MerchantModel]?) -> Void | 2391 | + completion: @escaping ([MerchantModel]?) -> Void, |
2392 | + failureCallback: @escaping (Int) -> Void | ||
2392 | ) { | 2393 | ) { |
2393 | // Handle language default inside the method | 2394 | // Handle language default inside the method |
2394 | let finalLanguage = language ?? self.applicationLocale | 2395 | let finalLanguage = language ?? self.applicationLocale |
... | @@ -2435,7 +2436,7 @@ public final class WarplySDK { | ... | @@ -2435,7 +2436,7 @@ public final class WarplySDK { |
2435 | dynatraceEvent._parameters = nil | 2436 | dynatraceEvent._parameters = nil |
2436 | self.postFrameworkEvent("dynatrace", sender: dynatraceEvent) | 2437 | self.postFrameworkEvent("dynatrace", sender: dynatraceEvent) |
2437 | 2438 | ||
2438 | - completion(merchantsArray) | 2439 | + failureCallback(-1) |
2439 | } | 2440 | } |
2440 | } | 2441 | } |
2441 | } catch { | 2442 | } catch { |
... | @@ -2445,7 +2446,11 @@ public final class WarplySDK { | ... | @@ -2445,7 +2446,11 @@ public final class WarplySDK { |
2445 | dynatraceEvent._parameters = nil | 2446 | dynatraceEvent._parameters = nil |
2446 | self.postFrameworkEvent("dynatrace", sender: dynatraceEvent) | 2447 | self.postFrameworkEvent("dynatrace", sender: dynatraceEvent) |
2447 | 2448 | ||
2448 | - completion(nil) | 2449 | + if let networkError = error as? NetworkError { |
2450 | + failureCallback(networkError.code) | ||
2451 | + } else { | ||
2452 | + failureCallback(-1) | ||
2453 | + } | ||
2449 | } | 2454 | } |
2450 | } | 2455 | } |
2451 | } | 2456 | } |
... | @@ -2461,7 +2466,8 @@ public final class WarplySDK { | ... | @@ -2461,7 +2466,8 @@ public final class WarplySDK { |
2461 | uuid: String = "", | 2466 | uuid: String = "", |
2462 | distance: Int = 0, | 2467 | distance: Int = 0, |
2463 | parentUuids: [String] = [], | 2468 | parentUuids: [String] = [], |
2464 | - completion: @escaping ([MerchantModel]?) -> Void | 2469 | + completion: @escaping ([MerchantModel]?) -> Void, |
2470 | + failureCallback: @escaping (Int) -> Void = { _ in } | ||
2465 | ) { | 2471 | ) { |
2466 | // Call new method with nil language (will use applicationLocale) | 2472 | // Call new method with nil language (will use applicationLocale) |
2467 | getMerchants( | 2473 | getMerchants( |
... | @@ -2473,7 +2479,8 @@ public final class WarplySDK { | ... | @@ -2473,7 +2479,8 @@ public final class WarplySDK { |
2473 | uuid: uuid, | 2479 | uuid: uuid, |
2474 | distance: distance, | 2480 | distance: distance, |
2475 | parentUuids: parentUuids, | 2481 | parentUuids: parentUuids, |
2476 | - completion: completion | 2482 | + completion: completion, |
2483 | + failureCallback: failureCallback | ||
2477 | ) | 2484 | ) |
2478 | } | 2485 | } |
2479 | 2486 | ||
... | @@ -2612,14 +2619,18 @@ public final class WarplySDK { | ... | @@ -2612,14 +2619,18 @@ public final class WarplySDK { |
2612 | tags: tags, | 2619 | tags: tags, |
2613 | uuid: uuid, | 2620 | uuid: uuid, |
2614 | distance: distance, | 2621 | distance: distance, |
2615 | - parentUuids: parentUuids | 2622 | + parentUuids: parentUuids, |
2616 | - ) { merchants in | 2623 | + completion: { merchants in |
2617 | if let merchants = merchants { | 2624 | if let merchants = merchants { |
2618 | continuation.resume(returning: merchants) | 2625 | continuation.resume(returning: merchants) |
2619 | } else { | 2626 | } else { |
2620 | continuation.resume(throwing: WarplyError.networkError) | 2627 | continuation.resume(throwing: WarplyError.networkError) |
2621 | } | 2628 | } |
2629 | + }, | ||
2630 | + failureCallback: { errorCode in | ||
2631 | + continuation.resume(throwing: WarplyError.unknownError(errorCode)) | ||
2622 | } | 2632 | } |
2633 | + ) | ||
2623 | } | 2634 | } |
2624 | } | 2635 | } |
2625 | 2636 | ... | ... |
-
Please register or login to post a comment