diff --git a/peekaboo-cli/Sources/peekaboo/ImageCommand.swift b/peekaboo-cli/Sources/peekaboo/ImageCommand.swift index 23e1452..cfad5ef 100644 --- a/peekaboo-cli/Sources/peekaboo/ImageCommand.swift +++ b/peekaboo-cli/Sources/peekaboo/ImageCommand.swift @@ -111,7 +111,7 @@ struct ImageCommand: ParsableCommand { .PERMISSION_ERROR_ACCESSIBILITY case .appNotFound: .APP_NOT_FOUND - case .windowNotFound: + case .windowNotFound, .noWindowsFound: .WINDOW_NOT_FOUND case .fileWriteError: .FILE_IO_ERROR @@ -224,7 +224,7 @@ struct ImageCommand: ParsableCommand { let windows = try WindowManager.getWindowsForApp(pid: targetApp.processIdentifier) guard !windows.isEmpty else { - throw CaptureError.windowNotFound + throw CaptureError.noWindowsFound(targetApp.localizedName ?? appIdentifier) } let targetWindow: WindowData @@ -270,7 +270,7 @@ struct ImageCommand: ParsableCommand { let windows = try WindowManager.getWindowsForApp(pid: targetApp.processIdentifier) guard !windows.isEmpty else { - throw CaptureError.windowNotFound + throw CaptureError.noWindowsFound(targetApp.localizedName ?? appIdentifier) } var savedFiles: [SavedFile] = [] diff --git a/peekaboo-cli/Sources/peekaboo/Models.swift b/peekaboo-cli/Sources/peekaboo/Models.swift index 8e95347..bc33452 100644 --- a/peekaboo-cli/Sources/peekaboo/Models.swift +++ b/peekaboo-cli/Sources/peekaboo/Models.swift @@ -112,6 +112,7 @@ enum CaptureError: Error, LocalizedError { case invalidWindowIndex(Int) case invalidArgument(String) case unknownError(String) + case noWindowsFound(String) var errorDescription: String? { switch self { @@ -158,6 +159,8 @@ enum CaptureError: Error, LocalizedError { return "Invalid argument: \(message)" case let .unknownError(message): return "An unexpected error occurred: \(message)" + case let .noWindowsFound(appName): + return "The '\(appName)' process is running, but no capturable windows were found." } } @@ -175,6 +178,7 @@ enum CaptureError: Error, LocalizedError { case .invalidWindowIndex: 19 case .invalidArgument: 20 case .unknownError: 1 + case .noWindowsFound: 7 } } } diff --git a/src/utils/peekaboo-cli.ts b/src/utils/peekaboo-cli.ts index 3a439fa..0103c79 100644 --- a/src/utils/peekaboo-cli.ts +++ b/src/utils/peekaboo-cli.ts @@ -64,6 +64,7 @@ function mapExitCodeToErrorMessage( : `Swift CLI execution failed (exit code: ${exitCode})`; const errorCodeMap: { [key: number]: { message: string, code: string } } = { 1: { message: "An unknown error occurred in the Swift CLI.", code: "SWIFT_CLI_UNKNOWN_ERROR" }, + 7: { message: "The specified application is running but has no capturable windows. Try setting 'capture_focus' to 'foreground' to un-hide application windows.", code: "SWIFT_CLI_NO_WINDOWS_FOUND" }, 10: { message: "No displays available for capture.", code: "SWIFT_CLI_NO_DISPLAYS" }, 11: { message: "Screen Recording permission is not granted. Please enable it in System Settings > Privacy & Security > Screen Recording.",