Skip to content

Commit

Permalink
Only validate the error when throwing it.
Browse files Browse the repository at this point in the history
  • Loading branch information
samsymons committed Nov 1, 2024
1 parent aff5f0c commit 7ab6025
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions Sources/NetworkProtection/PacketTunnelProvider.swift
Original file line number Diff line number Diff line change
Expand Up @@ -692,9 +692,6 @@ open class PacketTunnelProvider: NEPacketTunnelProvider {
throw TunnelError.startingTunnelWithoutAuthToken
}
} catch {
// Check that the error is valid and able to be re-thrown to the OS before shutting the tunnel down
let error = validated(error: error)

if startupOptions.startupMethod == .automaticOnDemand {
// If the VPN was started by on-demand without the basic prerequisites for
// it to work we skip firing pixels. This should only be possible if the
Expand All @@ -713,7 +710,8 @@ open class PacketTunnelProvider: NEPacketTunnelProvider {
Logger.networkProtection.log("🔴 Stopping VPN due to no auth token")
await attemptShutdownDueToRevokedAccess()

throw error
// Check that the error is valid and able to be re-thrown to the OS before shutting the tunnel down
throw validated(error: error)
}

do {
Expand All @@ -726,9 +724,6 @@ open class PacketTunnelProvider: NEPacketTunnelProvider {

providerEvents.fire(.tunnelStartAttempt(.success))
} catch {
// Check that the error is valid and able to be re-thrown to the OS before shutting the tunnel down
let error = validated(error: error)

if startupOptions.startupMethod == .automaticOnDemand {
// We add a delay when the VPN is started by
// on-demand and there's an error, to avoid frenetic ON/OFF
Expand All @@ -743,7 +738,9 @@ open class PacketTunnelProvider: NEPacketTunnelProvider {
self.knownFailureStore.lastKnownFailure = KnownFailure(error)

providerEvents.fire(.tunnelStartAttempt(.failure(error)))
throw error

Check failure on line 741 in Sources/NetworkProtection/PacketTunnelProvider.swift

View workflow job for this annotation

GitHub Actions / Run SwiftLint

Lines should not have trailing whitespace (trailing_whitespace)
// Check that the error is valid and able to be re-thrown to the OS before shutting the tunnel down
throw validated(error: error)
}
}

Expand Down

0 comments on commit 7ab6025

Please sign in to comment.