Tunnel errors: Consolidate tunnel activation errors into ErrorPresenter

Signed-off-by: Roopesh Chander <roop@roopc.net>
This commit is contained in:
Roopesh Chander
2018-11-01 16:58:33 +05:30
parent 39a457e402
commit 3611f8cf5a
3 changed files with 36 additions and 16 deletions
@@ -245,15 +245,11 @@ extension TunnelsListTableViewController {
cell.onSwitchToggled = { [weak self] isOn in
guard let s = self, let tunnelsManager = s.tunnelsManager else { return }
if (isOn) {
tunnelsManager.startActivation(of: tunnel) { error in
tunnelsManager.startActivation(of: tunnel) { [weak s] error in
if let error = error {
switch (error) {
case TunnelActivationError.noEndpoint:
self?.showErrorAlert(title: "Endpoint missing", message: "There must be at least one peer with an endpoint")
case TunnelActivationError.dnsResolutionFailed:
self?.showErrorAlert(title: "DNS Failure", message: "One or more endpoint domains could not be resolved")
default:
self?.showErrorAlert(title: "Internal error", message: "The tunnel could not be activated")
ErrorPresenter.showErrorAlert(error: error, from: s)
DispatchQueue.main.async {
cell.statusSwitch.isOn = false
}
}
}