Throw error on reinstate()/connect() (#328)
Errors here were just being ignored, thus preventing error alert from appearing.
This commit is contained in:
parent
a7ea010d4e
commit
33af87206a
|
@ -87,7 +87,7 @@ public final class VPNManager: ObservableObject {
|
||||||
clearLastError()
|
clearLastError()
|
||||||
do {
|
do {
|
||||||
let parameters = try vpnConfigurationParameters(withProfile: profile)
|
let parameters = try vpnConfigurationParameters(withProfile: profile)
|
||||||
await strategy.reinstate(parameters)
|
try await strategy.reinstate(parameters)
|
||||||
} catch {
|
} catch {
|
||||||
pp_log.error("Unable to build configuration: \(error)")
|
pp_log.error("Unable to build configuration: \(error)")
|
||||||
throw error
|
throw error
|
||||||
|
@ -99,7 +99,7 @@ public final class VPNManager: ObservableObject {
|
||||||
clearLastError()
|
clearLastError()
|
||||||
do {
|
do {
|
||||||
let parameters = try vpnConfigurationParameters(withProfile: profile)
|
let parameters = try vpnConfigurationParameters(withProfile: profile)
|
||||||
await strategy.connect(parameters)
|
try await strategy.connect(parameters)
|
||||||
} catch {
|
} catch {
|
||||||
pp_log.error("Unable to build configuration: \(error)")
|
pp_log.error("Unable to build configuration: \(error)")
|
||||||
throw error
|
throw error
|
||||||
|
|
|
@ -31,9 +31,9 @@ import PassepartoutProviders
|
||||||
public protocol VPNManagerStrategy {
|
public protocol VPNManagerStrategy {
|
||||||
func observe(into state: MutableObservableVPNState)
|
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
|
func reconnect() async
|
||||||
|
|
||||||
|
|
|
@ -132,10 +132,8 @@ extension TunnelKitVPNManagerStrategy {
|
||||||
}.store(in: &cancellables)
|
}.store(in: &cancellables)
|
||||||
}
|
}
|
||||||
|
|
||||||
public func reinstate(_ parameters: VPNConfigurationParameters) async {
|
public func reinstate(_ parameters: VPNConfigurationParameters) async throws {
|
||||||
guard let configuration = try? vpnConfiguration(withParameters: parameters) else {
|
let configuration = try vpnConfiguration(withParameters: parameters)
|
||||||
return
|
|
||||||
}
|
|
||||||
guard let vpnType = configuration.neConfiguration as? VPNProtocolProviding else {
|
guard let vpnType = configuration.neConfiguration as? VPNProtocolProviding else {
|
||||||
fatalError("Configuration must implement VPNProtocolProviding")
|
fatalError("Configuration must implement VPNProtocolProviding")
|
||||||
}
|
}
|
||||||
|
@ -155,10 +153,8 @@ extension TunnelKitVPNManagerStrategy {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public func connect(_ parameters: VPNConfigurationParameters) async {
|
public func connect(_ parameters: VPNConfigurationParameters) async throws {
|
||||||
guard let configuration = try? vpnConfiguration(withParameters: parameters) else {
|
let configuration = try vpnConfiguration(withParameters: parameters)
|
||||||
return
|
|
||||||
}
|
|
||||||
guard let vpnType = configuration.neConfiguration as? VPNProtocolProviding else {
|
guard let vpnType = configuration.neConfiguration as? VPNProtocolProviding else {
|
||||||
fatalError("Configuration must implement VPNProtocolProviding")
|
fatalError("Configuration must implement VPNProtocolProviding")
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue