UI: macOS: Show useful error message on .conf import
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
This commit is contained in:
parent
b286ede3c6
commit
26b7971ba6
|
@ -44,11 +44,21 @@ class TunnelImporter {
|
||||||
}
|
}
|
||||||
return
|
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 {
|
DispatchQueue.main.async {
|
||||||
if tunnelConfiguration == nil {
|
if parseError != nil {
|
||||||
|
if let parseError = parseError as? WireGuardAppError {
|
||||||
|
lastFileImportErrorText = parseError.alertText
|
||||||
|
} else {
|
||||||
lastFileImportErrorText = (title: tr("alertBadConfigImportTitle"), message: tr(format: "alertBadConfigImportMessage (%@)", fileName))
|
lastFileImportErrorText = (title: tr("alertBadConfigImportTitle"), message: tr(format: "alertBadConfigImportMessage (%@)", fileName))
|
||||||
}
|
}
|
||||||
|
}
|
||||||
configs.append(tunnelConfiguration)
|
configs.append(tunnelConfiguration)
|
||||||
dispatchGroup.leave()
|
dispatchGroup.leave()
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue