From 0dcb14d9a2b57658322ee171a15992fa0c7f7727 Mon Sep 17 00:00:00 2001 From: Jamil Date: Tue, 21 Jan 2025 21:32:10 -0800 Subject: [PATCH] refactor(apple): Downgrade error for repeated sysex enabling (#7816) If the user again clicks `Enable System Extension` without having actually enabled it in system settings, this error will be reported. We don't necessarily need to act on it. --- .../Sources/FirezoneKit/Views/GrantVPNView.swift | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/swift/apple/FirezoneKit/Sources/FirezoneKit/Views/GrantVPNView.swift b/swift/apple/FirezoneKit/Sources/FirezoneKit/Views/GrantVPNView.swift index 5966d3fb8..7e945bf42 100644 --- a/swift/apple/FirezoneKit/Sources/FirezoneKit/Views/GrantVPNView.swift +++ b/swift/apple/FirezoneKit/Sources/FirezoneKit/Views/GrantVPNView.swift @@ -8,6 +8,10 @@ import SwiftUI import Combine +#if os(macOS) +import SystemExtensions +#endif + @MainActor final class GrantVPNViewModel: ObservableObject { @Published var isInstalled: Bool = false @@ -33,13 +37,19 @@ final class GrantVPNViewModel: ObservableObject { do { try await store.installSystemExtension() - // The window has a tendency to go to the background after installing // the system extension NSApp.activate(ignoringOtherApps: true) } catch { - Log.error(error) + if let error = error as? OSSystemExtensionError, + case OSSystemExtensionError.requestSuperseded = error { // Code 12 + // This will happen if the user repeatedly clicks the `Enable` button + // before actually enabling it in system settings. + Log.info("\(#function): Request superseded: \(error)") + } else { + Log.error(error) + } } } }