From 050f8aa67961f81b76adfa7c5a2768da926c9bc4 Mon Sep 17 00:00:00 2001 From: Roopesh Chander Date: Thu, 1 Nov 2018 00:45:09 +0530 Subject: [PATCH] Tunnel edit: Error out on duplicate name when creating / modifying a tunnel Signed-off-by: Roopesh Chander --- .../WireGuard/UI/iOS/TunnelEditTableViewController.swift | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/WireGuard/WireGuard/UI/iOS/TunnelEditTableViewController.swift b/WireGuard/WireGuard/UI/iOS/TunnelEditTableViewController.swift index a536499..fac2b37 100644 --- a/WireGuard/WireGuard/UI/iOS/TunnelEditTableViewController.swift +++ b/WireGuard/WireGuard/UI/iOS/TunnelEditTableViewController.swift @@ -71,14 +71,13 @@ class TunnelEditTableViewController: UITableViewController { switch (tunnelSaveResult) { case .error(let errorMessage): let erroringConfiguration = (tunnelViewModel.interfaceData.validatedConfiguration == nil) ? "Interface" : "Peer" - showErrorAlert(title: "Invalid \(erroringConfiguration)", message: errorMessage) + ErrorPresenter.showErrorAlert(title: "Invalid \(erroringConfiguration)", message: errorMessage, from: self) case .saved(let tunnelConfiguration): if let tunnel = tunnel { // We're modifying an existing tunnel tunnelsManager.modify(tunnel: tunnel, with: tunnelConfiguration) { [weak self] (error) in if let error = error { - print("Could not modify tunnel: \(error)") - self?.showErrorAlert(title: "Could not save", message: "Internal error") + ErrorPresenter.showErrorAlert(error: error, from: self) } else { self?.dismiss(animated: true, completion: nil) self?.delegate?.tunnelSaved(tunnel: tunnel) @@ -88,8 +87,7 @@ class TunnelEditTableViewController: UITableViewController { // We're adding a new tunnel tunnelsManager.add(tunnelConfiguration: tunnelConfiguration) { [weak self] (tunnel, error) in if let error = error { - print("Could not add tunnel: \(error)") - self?.showErrorAlert(title: "Could not save", message: "Internal error") + ErrorPresenter.showErrorAlert(error: error, from: self) } else { self?.dismiss(animated: true, completion: nil) if let tunnel = tunnel {