TunnelErrors: Add alert text for PacketTunnelProviderError
This commit is contained in:
parent
baf99733f5
commit
09a96ec2a8
|
@ -64,6 +64,23 @@ enum TunnelsManagerActivationError: WireGuardAppError {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
extension PacketTunnelProviderError: WireGuardAppError {
|
||||||
|
var alertText: AlertText {
|
||||||
|
switch self {
|
||||||
|
case .savedProtocolConfigurationIsInvalid:
|
||||||
|
return (tr("alertTunnelActivationFailureTitle"), tr("alertTunnelActivationSavedConfigFailureMessage"))
|
||||||
|
case .dnsResolutionFailure:
|
||||||
|
return (tr("alertTunnelDNSFailureTitle"), tr("alertTunnelDNSFailureMessage"))
|
||||||
|
case .couldNotStartBackend:
|
||||||
|
return (tr("alertTunnelActivationFailureTitle"), tr("alertTunnelActivationBackendFailureMessage"))
|
||||||
|
case .couldNotDetermineFileDescriptor:
|
||||||
|
return (tr("alertTunnelActivationFailureTitle"), tr("alertTunnelActivationFileDescriptorFailureMessage"))
|
||||||
|
case .couldNotSetNetworkSettings:
|
||||||
|
return (tr("alertTunnelActivationFailureTitle"), tr("alertTunnelActivationSetNetworkSettingsMessage"))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
extension Error {
|
extension Error {
|
||||||
var localizedUIString: String {
|
var localizedUIString: String {
|
||||||
if let systemError = self as? NEVPNError {
|
if let systemError = self as? NEVPNError {
|
||||||
|
|
|
@ -323,20 +323,11 @@ private func lastErrorTextFromNetworkExtension(for tunnel: TunnelContainer) -> (
|
||||||
guard let lastErrorStrings = String(data: lastErrorData, encoding: .utf8)?.splitToArray(separator: "\n") else { return nil }
|
guard let lastErrorStrings = String(data: lastErrorData, encoding: .utf8)?.splitToArray(separator: "\n") else { return nil }
|
||||||
guard lastErrorStrings.count == 2 && tunnel.activationAttemptId == lastErrorStrings[0] else { return nil }
|
guard lastErrorStrings.count == 2 && tunnel.activationAttemptId == lastErrorStrings[0] else { return nil }
|
||||||
|
|
||||||
switch PacketTunnelProviderError(rawValue: lastErrorStrings[1]) {
|
if let extensionError = PacketTunnelProviderError(rawValue: lastErrorStrings[1]) {
|
||||||
case .some(.savedProtocolConfigurationIsInvalid):
|
return extensionError.alertText
|
||||||
return (tr("alertTunnelActivationFailureTitle"), tr("alertTunnelActivationSavedConfigFailureMessage"))
|
|
||||||
case .some(.dnsResolutionFailure):
|
|
||||||
return (tr("alertTunnelDNSFailureTitle"), tr("alertTunnelDNSFailureMessage"))
|
|
||||||
case .some(.couldNotStartBackend):
|
|
||||||
return (tr("alertTunnelActivationFailureTitle"), tr("alertTunnelActivationBackendFailureMessage"))
|
|
||||||
case .some(.couldNotDetermineFileDescriptor):
|
|
||||||
return (tr("alertTunnelActivationFailureTitle"), tr("alertTunnelActivationFileDescriptorFailureMessage"))
|
|
||||||
case .some(.couldNotSetNetworkSettings):
|
|
||||||
return (tr("alertTunnelActivationFailureTitle"), tr("alertTunnelActivationSetNetworkSettingsMessage"))
|
|
||||||
default:
|
|
||||||
return (tr("alertTunnelActivationFailureTitle"), tr("alertTunnelActivationFailureMessage"))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return (tr("alertTunnelActivationFailureTitle"), tr("alertTunnelActivationFailureMessage"))
|
||||||
}
|
}
|
||||||
|
|
||||||
class TunnelContainer: NSObject {
|
class TunnelContainer: NSObject {
|
||||||
|
|
Loading…
Reference in New Issue