aboutsummaryrefslogtreecommitdiffstats
path: root/WireGuard/WireGuard/UI/TunnelImporter.swift
diff options
context:
space:
mode:
authorRoopesh Chander <roop@roopc.net>2019-02-24 16:50:57 +0530
committerRoopesh Chander <roop@roopc.net>2019-02-24 16:50:57 +0530
commitab6d714070cddc357188cc6320595951824f68fc (patch)
tree989d83771c9fa97cc1d1c2460d6b75da0cdb3e9e /WireGuard/WireGuard/UI/TunnelImporter.swift
parentmacOS: Tunnel edit: Disable user interaction when OS VPN prompt is shown (diff)
downloadwireguard-apple-ab6d714070cddc357188cc6320595951824f68fc.tar.xz
wireguard-apple-ab6d714070cddc357188cc6320595951824f68fc.zip
Importing: Show OS error when unable to open a .conf file
Signed-off-by: Roopesh Chander <roop@roopc.net>
Diffstat (limited to 'WireGuard/WireGuard/UI/TunnelImporter.swift')
-rw-r--r--WireGuard/WireGuard/UI/TunnelImporter.swift10
1 files changed, 8 insertions, 2 deletions
diff --git a/WireGuard/WireGuard/UI/TunnelImporter.swift b/WireGuard/WireGuard/UI/TunnelImporter.swift
index 2c88219d..06148d33 100644
--- a/WireGuard/WireGuard/UI/TunnelImporter.swift
+++ b/WireGuard/WireGuard/UI/TunnelImporter.swift
@@ -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) {