Skip to content
This repository has been archived by the owner on Jun 20, 2023. It is now read-only.

Fix/2018 dont show ENError16 #1608

Merged
merged 3 commits into from
Dec 2, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 20 additions & 15 deletions src/xcode/ENA/ENA/Source/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ extension AppDelegate {
switch didEndPrematurelyReason {
case let .noExposureWindows(error):
return makeAlertController(
noSummaryError: error,
noExposureWindowsError: error,
localizedDescription: didEndPrematurelyReason.localizedDescription,
rootController: rootController
)
Expand All @@ -83,21 +83,26 @@ extension AppDelegate {
}
}

private func makeAlertController(noSummaryError: Error?, localizedDescription: String, rootController: UIViewController) -> UIAlertController? {
private func makeAlertController(noExposureWindowsError: Error?, localizedDescription: String, rootController: UIViewController) -> UIAlertController? {

if let enError = noSummaryError as? ENError {
let openFAQ: (() -> Void)? = {
guard let url = enError.faqURL else { return nil }
return {
UIApplication.shared.open(url, options: [:])
}
}()
return rootController.setupErrorAlert(
message: localizedDescription,
secondaryActionTitle: AppStrings.Common.errorAlertActionMoreInfo,
secondaryActionCompletion: openFAQ
)
} else if let exposureDetectionError = noSummaryError as? ExposureDetectionError {
if let enError = noExposureWindowsError as? ENError {
switch enError.code {
case .dataInaccessible:
return nil
default:
let openFAQ: (() -> Void)? = {
guard let url = enError.faqURL else { return nil }
return {
UIApplication.shared.open(url, options: [:])
}
}()
return rootController.setupErrorAlert(
message: localizedDescription,
secondaryActionTitle: AppStrings.Common.errorAlertActionMoreInfo,
secondaryActionCompletion: openFAQ
)
}
} else if let exposureDetectionError = noExposureWindowsError as? ExposureDetectionError {
switch exposureDetectionError {
case .isAlreadyRunning:
return nil
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,19 @@ extension ExposureDetectionViewController {
self?.state.riskState = .risk(risk)
self?.updateUI()
}

consumer.didFailCalculateRisk = { [weak self] error in

// Ignore already running errors.
guard !error.isAlreadyRunningError else {
Log.info("[ExposureDetectionViewController] Ignore already running error.", log: .riskDetection)
return
}

guard error.shouldBeDisplayedToUser else {
Log.info("[ExposureDetectionViewController] Don't show error to user: \(error).", log: .riskDetection)
return
}

switch error {
case .inactive:
Expand All @@ -83,6 +89,7 @@ extension ExposureDetectionViewController {

self?.updateUI()
}

consumer.didChangeActivityState = { [weak self] activityState in
self?.state.activityState = activityState
}
Expand Down
5 changes: 5 additions & 0 deletions src/xcode/ENA/ENA/Source/Scenes/Home/HomeInteractor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,11 @@ final class HomeInteractor: RequiresAppDependencies {
return
}

guard error.shouldBeDisplayedToUser else {
Log.info("[HomeInteractor] Don't show error to user: \(error).", log: .riskDetection)
return
}

switch error {
case .inactive:
self.state.riskState = .inactive
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
//

import Foundation
import ExposureNotification

typealias RiskProviderResult = Result<Risk, RiskProviderError>

Expand Down Expand Up @@ -33,6 +34,20 @@ enum RiskProviderError: Error {

return false
}

var shouldBeDisplayedToUser: Bool {
!isENError16DataInaccessible
}

private var isENError16DataInaccessible: Bool {
guard case let .failedRiskDetection(didEndPrematuralyReason) = self,
case let .noExposureWindows(noExposureWindowsError) = didEndPrematuralyReason,
let enError = noExposureWindowsError as? ENError else {
return false
}

return enError.code == .dataInaccessible
}
}

enum RiskProviderActivityState {
Expand Down