]> git.ipfire.org Git - thirdparty/wireguard-apple.git/commitdiff
Importing: Show OS error when unable to open a .conf file
authorRoopesh Chander <roop@roopc.net>
Sun, 24 Feb 2019 11:20:57 +0000 (16:50 +0530)
committerRoopesh Chander <roop@roopc.net>
Sun, 24 Feb 2019 11:20:57 +0000 (16:50 +0530)
Signed-off-by: Roopesh Chander <roop@roopc.net>
WireGuard/WireGuard/UI/TunnelImporter.swift

index 2c88219d1705d6a5fa47f8c26416f82876ccf73b..06148d335a02c0f68f5df8c154521ca130ab6e63 100644 (file)
@@ -28,8 +28,14 @@ class TunnelImporter {
             let fileContents: String
             do {
                 fileContents = try String(contentsOf: url)
-            } catch {
-                errorPresenterType.showErrorAlert(title: tr("alertCantOpenInputConfFileTitle"), message: tr(format: "alertCantOpenInputConfFileMessage (%@)", fileName), from: sourceVC, onPresented: completionHandler)
+            } catch let error {
+                let message: String
+                if let cocoaError = error as? CocoaError, cocoaError.isFileError {
+                    message = error.localizedDescription
+                } else {
+                    message = tr(format: "alertCantOpenInputConfFileMessage (%@)", fileName)
+                }
+                errorPresenterType.showErrorAlert(title: tr("alertCantOpenInputConfFileTitle"), message: message, from: sourceVC, onPresented: completionHandler)
                 return
             }
             if let tunnelConfiguration = try? TunnelConfiguration(fromWgQuickConfig: fileContents, called: fileBaseName) {