Skip to content

Commit

Permalink
wishlist corona-warn-app#589: add timestamp to ENError message
Browse files Browse the repository at this point in the history
  • Loading branch information
ndegendogo committed Aug 22, 2021
1 parent f0ed32c commit b4174bd
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -620,10 +620,11 @@ class AppDelegate: UIResponder, UIApplicationDelegate, CoronaWarnAppDelegate, Re
switch riskProviderError {
case .failedRiskDetection(let didEndPrematurelyReason):
switch didEndPrematurelyReason {
case let .noExposureWindows(error):
case let .noExposureWindows(error, date):
return makeAlertController(
noExposureWindowsError: error,
localizedDescription: didEndPrematurelyReason.localizedDescription,
date: date,
rootController: rootController
)
case .wrongDeviceTime:
Expand All @@ -649,7 +650,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate, CoronaWarnAppDelegate, Re
}
}

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

if let enError = noExposureWindowsError as? ENError {
switch enError.code {
Expand All @@ -663,7 +664,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate, CoronaWarnAppDelegate, Re
}
}()
return rootController.setupErrorAlert(
message: localizedDescription,
message: localizedDescription + "\n\(date)",
secondaryActionTitle: AppStrings.Common.errorAlertActionMoreInfo,
secondaryActionCompletion: openFAQ
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ final class ExposureDetection {
case .success(let exposureWindows):
didDetectExposureWindows(exposureWindows)
case .failure(let error):
endPrematurely(reason: .noExposureWindows(error))
endPrematurely(reason: .noExposureWindows(error, Date()))
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ extension ExposureDetection {
/// Delegate was unable to provide an exposure manager to the transaction.
case noExposureManager
/// The actual exposure detection was started but did produce an error.
case noExposureWindows(Error)
case noExposureWindows(Error, Date)
/// It was not possible to determine the remote days and/or hours that can be loaded.
case noDaysAndHours
/// Unable to get exposure configuration
Expand All @@ -31,7 +31,7 @@ extension ExposureDetection.DidEndPrematurelyReason: LocalizedError {
return AppStrings.ExposureDetectionError.errorAlertMessage + " Code: NoExposureManager"
case .unableToWriteDiagnosisKeys:
return AppStrings.ExposureDetectionError.errorAlertMessage + " Code: DiagnosisKeys"
case .noExposureWindows(let error):
case .noExposureWindows(let error, _):
if let enError = error as? ENError {
switch enError.code {
case .unsupported:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ enum RiskProviderError: Error {
case .failedKeyPackageDownload(let keyPackageDownloadError):
return keyPackageDownloadError == .downloadIsRunning
case .failedRiskDetection(let didEndPrematuralyReason):
if case let .noExposureWindows(exposureWindowsError) = didEndPrematuralyReason {
if case let .noExposureWindows(exposureWindowsError, _) = didEndPrematuralyReason {
if let exposureDetectionError = exposureWindowsError as? ExposureDetectionError {
return exposureDetectionError == .isAlreadyRunning
}
Expand All @@ -42,7 +42,7 @@ enum RiskProviderError: Error {

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

0 comments on commit b4174bd

Please sign in to comment.