aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2019-06-28 12:06:58 +0200
committerJason A. Donenfeld <Jason@zx2c4.com>2019-06-28 12:07:18 +0200
commit8352559c513eda7cffe34337045cae655138f887 (patch)
tree81c3b40171a6d2d76db9d6f1d1282274163ff04e
parentiOS: Importing: If tunnelsManager isn't ready yet, we should wait for it (diff)
downloadwireguard-apple-8352559c513eda7cffe34337045cae655138f887.tar.xz
wireguard-apple-8352559c513eda7cffe34337045cae655138f887.zip
UI: macOS: Show useful error message on .conf import
-rw-r--r--WireGuard/WireGuard/UI/TunnelImporter.swift16
1 files changed, 13 insertions, 3 deletions
diff --git a/WireGuard/WireGuard/UI/TunnelImporter.swift b/WireGuard/WireGuard/UI/TunnelImporter.swift
index cf05ff9..46f2c92 100644
--- a/WireGuard/WireGuard/UI/TunnelImporter.swift
+++ b/WireGuard/WireGuard/UI/TunnelImporter.swift
@@ -44,10 +44,20 @@ class TunnelImporter {
}
return
}
- let tunnelConfiguration = try? TunnelConfiguration(fromWgQuickConfig: fileContents, called: fileBaseName)
+ var parseError: Error?
+ var tunnelConfiguration: TunnelConfiguration?
+ do {
+ tunnelConfiguration = try TunnelConfiguration(fromWgQuickConfig: fileContents, called: fileBaseName)
+ } catch let error {
+ parseError = error
+ }
DispatchQueue.main.async {
- if tunnelConfiguration == nil {
- lastFileImportErrorText = (title: tr("alertBadConfigImportTitle"), message: tr(format: "alertBadConfigImportMessage (%@)", fileName))
+ if parseError != nil {
+ if let parseError = parseError as? WireGuardAppError {
+ lastFileImportErrorText = parseError.alertText
+ } else {
+ lastFileImportErrorText = (title: tr("alertBadConfigImportTitle"), message: tr(format: "alertBadConfigImportMessage (%@)", fileName))
+ }
}
configs.append(tunnelConfiguration)
dispatchGroup.leave()