summaryrefslogtreecommitdiffhomepage
path: root/ios
diff options
context:
space:
mode:
authorAndrej Mihajlov <and@mullvad.net>2021-05-05 10:54:04 +0200
committerAndrej Mihajlov <and@mullvad.net>2021-05-05 10:56:34 +0200
commitcdea0cf3498c511bb3e9883801d8c09494e99ea1 (patch)
tree770070fa9594cca4191460c05169af929ce4a9c6 /ios
parente1115c30f7872e3152a31ac1b240631d3dd09ed6 (diff)
downloadmullvadvpn-cdea0cf3498c511bb3e9883801d8c09494e99ea1.tar.xz
mullvadvpn-cdea0cf3498c511bb3e9883801d8c09494e99ea1.zip
AppDelegate: extract tunnel error presentation into a function
Diffstat (limited to 'ios')
-rw-r--r--ios/MullvadVPN/AppDelegate.swift37
1 files changed, 15 insertions, 22 deletions
diff --git a/ios/MullvadVPN/AppDelegate.swift b/ios/MullvadVPN/AppDelegate.swift
index 7f356e6e97..3276d5c433 100644
--- a/ios/MullvadVPN/AppDelegate.swift
+++ b/ios/MullvadVPN/AppDelegate.swift
@@ -378,17 +378,7 @@ extension AppDelegate: ConnectViewControllerDelegate {
case .failure(let error):
self.logger?.error(chainedError: error, message: "Failed to start the VPN tunnel")
-
- let alertController = UIAlertController(
- title: NSLocalizedString("Failed to start the VPN tunnel", comment: ""),
- message: error.errorChainDescription,
- preferredStyle: .alert
- )
- alertController.addAction(
- UIAlertAction(title: NSLocalizedString("OK", comment: ""), style: .cancel)
- )
-
- self.alertPresenter.enqueue(alertController, presentingController: self.rootContainer!)
+ self.presentTunnelError(error, alertTitle: NSLocalizedString("Failed to start the VPN tunnel", comment: ""))
}
}
}
@@ -402,20 +392,23 @@ extension AppDelegate: ConnectViewControllerDelegate {
case .failure(let error):
self.logger?.error(chainedError: error, message: "Failed to stop the VPN tunnel")
-
- let alertController = UIAlertController(
- title: NSLocalizedString("Failed to stop the VPN tunnel", comment: ""),
- message: error.errorChainDescription,
- preferredStyle: .alert
- )
- alertController.addAction(
- UIAlertAction(title: NSLocalizedString("OK", comment: ""), style: .cancel)
- )
-
- self.alertPresenter.enqueue(alertController, presentingController: self.rootContainer!)
+ self.presentTunnelError(error, alertTitle: NSLocalizedString("Failed to stop the VPN tunnel", comment: ""))
}
}
}
+
+ private func presentTunnelError(_ error: TunnelManager.Error, alertTitle: String) {
+ let alertController = UIAlertController(
+ title: alertTitle,
+ message: error.errorChainDescription,
+ preferredStyle: .alert
+ )
+ alertController.addAction(
+ UIAlertAction(title: NSLocalizedString("OK", comment: ""), style: .cancel)
+ )
+
+ self.alertPresenter.enqueue(alertController, presentingController: self.rootContainer!)
+ }
}
// MARK: - SelectLocationViewControllerDelegate