Throw error on reinstate()/connect() (#328)

Errors here were just being ignored, thus preventing error alert from
appearing.
This commit is contained in:
Davide De Rosa 2023-07-06 18:45:43 +01:00 committed by GitHub
parent a7ea010d4e
commit 33af87206a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 12 deletions

View File

@ -87,7 +87,7 @@ public final class VPNManager: ObservableObject {
clearLastError()
do {
let parameters = try vpnConfigurationParameters(withProfile: profile)
await strategy.reinstate(parameters)
try await strategy.reinstate(parameters)
} catch {
pp_log.error("Unable to build configuration: \(error)")
throw error
@ -99,7 +99,7 @@ public final class VPNManager: ObservableObject {
clearLastError()
do {
let parameters = try vpnConfigurationParameters(withProfile: profile)
await strategy.connect(parameters)
try await strategy.connect(parameters)
} catch {
pp_log.error("Unable to build configuration: \(error)")
throw error

View File

@ -31,9 +31,9 @@ import PassepartoutProviders
public protocol VPNManagerStrategy {
func observe(into state: MutableObservableVPNState)
func reinstate(_ parameters: VPNConfigurationParameters) async
func reinstate(_ parameters: VPNConfigurationParameters) async throws
func connect(_ parameters: VPNConfigurationParameters) async
func connect(_ parameters: VPNConfigurationParameters) async throws
func reconnect() async

View File

@ -132,10 +132,8 @@ extension TunnelKitVPNManagerStrategy {
}.store(in: &cancellables)
}
public func reinstate(_ parameters: VPNConfigurationParameters) async {
guard let configuration = try? vpnConfiguration(withParameters: parameters) else {
return
}
public func reinstate(_ parameters: VPNConfigurationParameters) async throws {
let configuration = try vpnConfiguration(withParameters: parameters)
guard let vpnType = configuration.neConfiguration as? VPNProtocolProviding else {
fatalError("Configuration must implement VPNProtocolProviding")
}
@ -155,10 +153,8 @@ extension TunnelKitVPNManagerStrategy {
}
}
public func connect(_ parameters: VPNConfigurationParameters) async {
guard let configuration = try? vpnConfiguration(withParameters: parameters) else {
return
}
public func connect(_ parameters: VPNConfigurationParameters) async throws {
let configuration = try vpnConfiguration(withParameters: parameters)
guard let vpnType = configuration.neConfiguration as? VPNProtocolProviding else {
fatalError("Configuration must implement VPNProtocolProviding")
}