Apply SwiftFormat changes

This commit is contained in:
Peter Steinberger 2025-06-07 22:58:07 +01:00
parent 27f229e802
commit 94c09b1c7a
3 changed files with 26 additions and 28 deletions

View file

@ -97,32 +97,30 @@ struct ImageCommand: ParsableCommand {
} }
private func handleError(_ error: Error) { private func handleError(_ error: Error) {
let captureError: CaptureError let captureError: CaptureError = if let err = error as? CaptureError {
if let err = error as? CaptureError { err
captureError = err
} else { } else {
captureError = .unknownError(error.localizedDescription) .unknownError(error.localizedDescription)
} }
if jsonOutput { if jsonOutput {
let code: ErrorCode let code: ErrorCode = switch captureError {
switch captureError {
case .screenRecordingPermissionDenied: case .screenRecordingPermissionDenied:
code = .PERMISSION_ERROR_SCREEN_RECORDING .PERMISSION_ERROR_SCREEN_RECORDING
case .accessibilityPermissionDenied: case .accessibilityPermissionDenied:
code = .PERMISSION_ERROR_ACCESSIBILITY .PERMISSION_ERROR_ACCESSIBILITY
case .appNotFound: case .appNotFound:
code = .APP_NOT_FOUND .APP_NOT_FOUND
case .windowNotFound: case .windowNotFound:
code = .WINDOW_NOT_FOUND .WINDOW_NOT_FOUND
case .fileWriteError: case .fileWriteError:
code = .FILE_IO_ERROR .FILE_IO_ERROR
case .invalidArgument: case .invalidArgument:
code = .INVALID_ARGUMENT .INVALID_ARGUMENT
case .unknownError: case .unknownError:
code = .UNKNOWN_ERROR .UNKNOWN_ERROR
default: default:
code = .CAPTURE_FAILED .CAPTURE_FAILED
} }
outputError( outputError(
message: captureError.localizedDescription, message: captureError.localizedDescription,

View file

@ -144,18 +144,18 @@ enum CaptureError: Error, LocalizedError {
var exitCode: Int32 { var exitCode: Int32 {
switch self { switch self {
case .noDisplaysAvailable: return 10 case .noDisplaysAvailable: 10
case .screenRecordingPermissionDenied: return 11 case .screenRecordingPermissionDenied: 11
case .accessibilityPermissionDenied: return 12 case .accessibilityPermissionDenied: 12
case .invalidDisplayID: return 13 case .invalidDisplayID: 13
case .captureCreationFailed: return 14 case .captureCreationFailed: 14
case .windowNotFound: return 15 case .windowNotFound: 15
case .windowCaptureFailed: return 16 case .windowCaptureFailed: 16
case .fileWriteError: return 17 case .fileWriteError: 17
case .appNotFound: return 18 case .appNotFound: 18
case .invalidWindowIndex: return 19 case .invalidWindowIndex: 19
case .invalidArgument: return 20 case .invalidArgument: 20
case .unknownError: return 1 case .unknownError: 1
} }
} }
} }