]> git.ipfire.org Git - thirdparty/wireguard-apple.git/commitdiff
Error handling: alertText() can be nil
authorRoopesh Chander <roop@roopc.net>
Mon, 10 Dec 2018 19:00:33 +0000 (00:30 +0530)
committerRoopesh Chander <roop@roopc.net>
Mon, 10 Dec 2018 19:04:22 +0000 (00:34 +0530)
Indicating that no alert is to be shown for that error.

Signed-off-by: Roopesh Chander <roop@roopc.net>
WireGuard/WireGuard/UI/iOS/ErrorPresenter.swift
WireGuard/WireGuard/VPN/TunnelsManager.swift
WireGuard/WireGuard/WireGuardAppError.swift
WireGuard/WireGuard/ZipArchive/ZipArchive.swift
WireGuard/WireGuard/ZipArchive/ZipExporter.swift
WireGuard/WireGuard/ZipArchive/ZipImporter.swift

index 3c4a1bf3da7e89de2b93a153b53887914daac8cb..c613d67b068e223a7baa2eb17b42cf59aed6c90c 100644 (file)
@@ -8,7 +8,7 @@ class ErrorPresenter {
     static func showErrorAlert(error: WireGuardAppError, from sourceVC: UIViewController?,
                                onDismissal: (() -> Void)? = nil, onPresented: (() -> Void)? = nil) {
         guard let sourceVC = sourceVC else { return }
-        let (title, message) = error.alertText()
+        guard let (title, message) = error.alertText() else { return }
         let okAction = UIAlertAction(title: "OK", style: .default) { (_) in
             onDismissal?()
         }
index b36c9f8f0998a28c99a031424f5e54ab695810ea..9d04e1f3c47e570ad65f62215a823f8eaa925489 100644 (file)
@@ -31,7 +31,7 @@ enum TunnelsManagerError: WireGuardAppError {
     case tunnelActivationFailedInternalError // startTunnel() succeeded, but activation failed
     case tunnelActivationFailedNoInternetConnection // startTunnel() succeeded, but activation failed since no internet
 
-    func alertText() -> (String, String) {
+    func alertText() -> (String, String)? {
         switch (self) {
         case .tunnelNameEmpty:
             return ("No name provided", "Can't create tunnel with an empty name")
index 5289633417f7f24be0a9fd8187a0cd97d65ad193..3e4707d6b42135cf96d61bc9442adfbf2956a415 100644 (file)
@@ -2,5 +2,5 @@
 // Copyright © 2018 WireGuard LLC. All Rights Reserved.
 
 protocol WireGuardAppError: Error {
-    func alertText() -> (/* title */ String, /* message */ String)
+    func alertText() -> (/* title */ String, /* message */ String)?
 }
index fe633d0ffbfdf300d29b9237cb3963382b3a40f9..a849daa38a51d8c77a93c95a1ff3469cfe084a47 100644 (file)
@@ -8,7 +8,7 @@ enum ZipArchiveError: WireGuardAppError {
     case cantOpenOutputZipFileForWriting
     case badArchive
 
-    func alertText() -> (String, String) {
+    func alertText() -> (String, String)? {
         switch (self) {
         case .cantOpenInputZipFile:
             return ("Unable to read zip archive", "The zip archive could not be read.")
index a4e9d7ac7f80b51961d40917543e84629b364914..4f576138fd4e5af697f5dfe93992a3b2794e08f2 100644 (file)
@@ -6,7 +6,7 @@ import UIKit
 enum ZipExporterError: WireGuardAppError {
     case noTunnelsToExport
 
-    func alertText() -> (String, String) {
+    func alertText() -> (String, String)? {
         switch (self) {
         case .noTunnelsToExport:
             return ("Nothing to export", "There are no tunnels to export")
index 507a823d03a3207955b38a4eed080689aeded2a4..d281fb689c653a91b36f9451b179b8c467fa7c72 100644 (file)
@@ -6,7 +6,7 @@ import UIKit
 enum ZipImporterError: WireGuardAppError {
     case noTunnelsInZipArchive
 
-    func alertText() -> (String, String) {
+    func alertText() -> (String, String)? {
         switch (self) {
         case .noTunnelsInZipArchive:
             return ("No tunnels in zip archive", "No .conf tunnel files were found inside the zip archive.")