Peekaboo/peekaboo-cli/Sources/peekaboo/PermissionErrorDetector.swift
Peter Steinberger c04b8e7af0 Migrate to Swift 6 with strict concurrency
- Update to swift-tools-version 6.0 and enable StrictConcurrency
- Make all data models and types Sendable for concurrency safety
- Migrate commands from ParsableCommand to AsyncParsableCommand
- Remove AsyncUtils.swift and synchronous bridging patterns
- Update WindowBounds property names to snake_case for consistency
- Ensure all error types conform to Sendable protocol
- Add comprehensive Swift 6 migration documentation

This migration enables full Swift 6 concurrency checking and data race
safety while maintaining backward compatibility with the existing API.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-06-08 11:23:10 +01:00

35 lines
1.3 KiB
Swift

import Foundation
struct PermissionErrorDetector: Sendable {
static func isScreenRecordingPermissionError(_ error: Error) -> Bool {
let errorString = error.localizedDescription.lowercased()
// Check for specific screen recording related errors
if errorString.contains("screen recording") {
return true
}
// Check for NSError codes specific to screen capture permissions
if let nsError = error as NSError? {
// ScreenCaptureKit specific error codes
if nsError.domain == "com.apple.screencapturekit" && nsError.code == -3801 {
// SCStreamErrorUserDeclined = -3801
return true
}
// CoreGraphics error codes for screen capture
if nsError.domain == "com.apple.coregraphics" && nsError.code == 1002 {
// kCGErrorCannotComplete when permissions are denied
return true
}
}
// Only consider it a permission error if it mentions both "permission" and capture-related terms
if errorString.contains("permission") &&
(errorString.contains("capture") || errorString.contains("recording") || errorString.contains("screen")) {
return true
}
return false
}
}