From: Roopesh Chander Date: Sun, 24 Feb 2019 11:20:57 +0000 (+0530) Subject: Importing: Show OS error when unable to open a .conf file X-Git-Tag: 0.0.20190319-1~59 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ab6d714070cddc357188cc6320595951824f68fc;p=thirdparty%2Fwireguard-apple.git Importing: Show OS error when unable to open a .conf file Signed-off-by: Roopesh Chander --- diff --git a/WireGuard/WireGuard/UI/TunnelImporter.swift b/WireGuard/WireGuard/UI/TunnelImporter.swift index 2c88219..06148d3 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) {