fix: Remove unused Error codes (#1887)

* fix: Remove unused Errors

* Errors.kt -> CameraError.kt

* fix: remove .system
This commit is contained in:
Marc Rousavy 2023-09-29 21:54:35 +02:00 committed by GitHub
parent cf1952d8f7
commit 85564d6d02
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 2 additions and 66 deletions

View File

@ -32,7 +32,6 @@ enum PermissionError: String {
enum ParameterError { enum ParameterError {
case invalid(unionName: String, receivedValue: String) case invalid(unionName: String, receivedValue: String)
case unsupportedOS(unionName: String, receivedValue: String, supportedOnOs: String)
case unsupportedOutput(outputDescriptor: String) case unsupportedOutput(outputDescriptor: String)
case unsupportedInput(inputDescriptor: String) case unsupportedInput(inputDescriptor: String)
case invalidCombination(provided: String, missing: String) case invalidCombination(provided: String, missing: String)
@ -41,8 +40,6 @@ enum ParameterError {
switch self { switch self {
case .invalid: case .invalid:
return "invalid-parameter" return "invalid-parameter"
case .unsupportedOS:
return "unsupported-os"
case .unsupportedOutput: case .unsupportedOutput:
return "unsupported-output" return "unsupported-output"
case .unsupportedInput: case .unsupportedInput:
@ -56,8 +53,6 @@ enum ParameterError {
switch self { switch self {
case let .invalid(unionName: unionName, receivedValue: receivedValue): case let .invalid(unionName: unionName, receivedValue: receivedValue):
return "The value \"\(receivedValue)\" could not be parsed to type \(unionName)!" return "The value \"\(receivedValue)\" could not be parsed to type \(unionName)!"
case let .unsupportedOS(unionName: unionName, receivedValue: receivedValue, supportedOnOs: os):
return "The value \"\(receivedValue)\" for type \(unionName) is not supported on the current iOS version! Required OS: \(os) or higher"
case let .unsupportedOutput(outputDescriptor: output): case let .unsupportedOutput(outputDescriptor: output):
return "The output \"\(output)\" is not supported!" return "The output \"\(output)\" is not supported!"
case let .unsupportedInput(inputDescriptor: input): case let .unsupportedInput(inputDescriptor: input):
@ -148,7 +143,6 @@ enum FormatError {
enum SessionError { enum SessionError {
case cameraNotReady case cameraNotReady
case audioSessionSetupFailed(reason: String)
case audioSessionFailedToActivate case audioSessionFailedToActivate
case audioInUseByOtherApp case audioInUseByOtherApp
@ -156,8 +150,6 @@ enum SessionError {
switch self { switch self {
case .cameraNotReady: case .cameraNotReady:
return "camera-not-ready" return "camera-not-ready"
case .audioSessionSetupFailed:
return "audio-session-setup-failed"
case .audioInUseByOtherApp: case .audioInUseByOtherApp:
return "audio-in-use-by-other-app" return "audio-in-use-by-other-app"
case .audioSessionFailedToActivate: case .audioSessionFailedToActivate:
@ -169,8 +161,6 @@ enum SessionError {
switch self { switch self {
case .cameraNotReady: case .cameraNotReady:
return "The Camera is not ready yet! Wait for the onInitialized() callback!" return "The Camera is not ready yet! Wait for the onInitialized() callback!"
case let .audioSessionSetupFailed(reason):
return "The audio session failed to setup! \(reason)"
case .audioInUseByOtherApp: case .audioInUseByOtherApp:
return "The audio session is already in use by another app with higher priority!" return "The audio session is already in use by another app with higher priority!"
case .audioSessionFailedToActivate: case .audioSessionFailedToActivate:
@ -182,13 +172,11 @@ enum SessionError {
// MARK: - CaptureError // MARK: - CaptureError
enum CaptureError { enum CaptureError {
case invalidPhotoFormat
case recordingInProgress case recordingInProgress
case noRecordingInProgress case noRecordingInProgress
case fileError case fileError
case createTempFileError case createTempFileError
case createRecorderError(message: String? = nil) case createRecorderError(message: String? = nil)
case invalidPhotoCodec
case videoNotEnabled case videoNotEnabled
case photoNotEnabled case photoNotEnabled
case aborted case aborted
@ -196,8 +184,6 @@ enum CaptureError {
var code: String { var code: String {
switch self { switch self {
case .invalidPhotoFormat:
return "invalid-photo-format"
case .recordingInProgress: case .recordingInProgress:
return "recording-in-progress" return "recording-in-progress"
case .noRecordingInProgress: case .noRecordingInProgress:
@ -208,8 +194,6 @@ enum CaptureError {
return "create-temp-file-error" return "create-temp-file-error"
case .createRecorderError: case .createRecorderError:
return "create-recorder-error" return "create-recorder-error"
case .invalidPhotoCodec:
return "invalid-photo-codec"
case .videoNotEnabled: case .videoNotEnabled:
return "video-not-enabled" return "video-not-enabled"
case .photoNotEnabled: case .photoNotEnabled:
@ -223,10 +207,6 @@ enum CaptureError {
var message: String { var message: String {
switch self { switch self {
case .invalidPhotoFormat:
return "The given photo format was invalid!"
case .invalidPhotoCodec:
return "The given photo codec was invalid!"
case .recordingInProgress: case .recordingInProgress:
return "There is already an active video recording in progress! Did you call startRecording() twice?" return "There is already an active video recording in progress! Did you call startRecording() twice?"
case .noRecordingInProgress: case .noRecordingInProgress:
@ -249,26 +229,6 @@ enum CaptureError {
} }
} }
// MARK: - SystemError
enum SystemError: String {
case noManager = "no-camera-manager"
case frameProcessorsUnavailable = "frame-processors-unavailable"
var code: String {
return rawValue
}
var message: String {
switch self {
case .noManager:
return "No Camera Manager was found."
case .frameProcessorsUnavailable:
return "Frame Processors are unavailable - is react-native-worklets-core installed?"
}
}
}
// MARK: - CameraError // MARK: - CameraError
enum CameraError: Error { enum CameraError: Error {
@ -278,7 +238,6 @@ enum CameraError: Error {
case format(_ id: FormatError) case format(_ id: FormatError)
case session(_ id: SessionError) case session(_ id: SessionError)
case capture(_ id: CaptureError) case capture(_ id: CaptureError)
case system(_ id: SystemError)
case unknown(message: String? = nil) case unknown(message: String? = nil)
var code: String { var code: String {
@ -295,8 +254,6 @@ enum CameraError: Error {
return "session/\(id.code)" return "session/\(id.code)"
case let .capture(id: id): case let .capture(id: id):
return "capture/\(id.code)" return "capture/\(id.code)"
case let .system(id: id):
return "system/\(id.code)"
case .unknown: case .unknown:
return "unknown/unknown" return "unknown/unknown"
} }
@ -316,8 +273,6 @@ enum CameraError: Error {
return id.message return id.message
case let .capture(id: id): case let .capture(id: id):
return id.message return id.message
case let .system(id: id):
return id.message
case let .unknown(message: message): case let .unknown(message: message):
return message ?? "An unexpected error occured." return message ?? "An unexpected error occured."
} }

View File

@ -22,7 +22,8 @@ extension AVCaptureVideoStabilizationMode {
self = .cinematicExtended self = .cinematicExtended
return return
} else { } else {
throw EnumParserError.unsupportedOS(supportedOnOS: "iOS 13.0") self = .cinematic
return
} }
case "off": case "off":
self = .off self = .off

View File

@ -12,10 +12,6 @@ import Foundation
An error raised when the given descriptor (TypeScript string union type) cannot be parsed and converted to a Swift enum. An error raised when the given descriptor (TypeScript string union type) cannot be parsed and converted to a Swift enum.
*/ */
enum EnumParserError: Error { enum EnumParserError: Error {
/**
Raised when the descriptor is not supported on the current OS.
*/
case unsupportedOS(supportedOnOS: String)
/** /**
Raised when the descriptor does not match any of the possible values. Raised when the descriptor does not match any of the possible values.
*/ */

View File

@ -1,7 +1,6 @@
export type PermissionError = 'permission/microphone-permission-denied' | 'permission/camera-permission-denied' export type PermissionError = 'permission/microphone-permission-denied' | 'permission/camera-permission-denied'
export type ParameterError = export type ParameterError =
| 'parameter/invalid-parameter' | 'parameter/invalid-parameter'
| 'parameter/unsupported-os'
| 'parameter/unsupported-output' | 'parameter/unsupported-output'
| 'parameter/unsupported-input' | 'parameter/unsupported-input'
| 'parameter/invalid-combination' | 'parameter/invalid-combination'
@ -9,7 +8,6 @@ export type DeviceError =
| 'device/configuration-error' | 'device/configuration-error'
| 'device/no-device' | 'device/no-device'
| 'device/invalid-device' | 'device/invalid-device'
| 'device/torch-unavailable'
| 'device/microphone-unavailable' | 'device/microphone-unavailable'
| 'device/pixel-format-not-supported' | 'device/pixel-format-not-supported'
| 'device/low-light-boost-not-supported' | 'device/low-light-boost-not-supported'
@ -19,34 +17,20 @@ export type FormatError =
| 'format/invalid-fps' | 'format/invalid-fps'
| 'format/invalid-hdr' | 'format/invalid-hdr'
| 'format/incompatible-pixel-format-with-hdr-setting' | 'format/incompatible-pixel-format-with-hdr-setting'
| 'format/invalid-low-light-boost'
| 'format/invalid-format' | 'format/invalid-format'
| 'format/invalid-color-space'
export type SessionError = export type SessionError =
| 'session/camera-not-ready' | 'session/camera-not-ready'
| 'session/camera-cannot-be-opened' | 'session/camera-cannot-be-opened'
| 'session/camera-has-been-disconnected' | 'session/camera-has-been-disconnected'
| 'session/audio-session-setup-failed'
| 'session/audio-in-use-by-other-app' | 'session/audio-in-use-by-other-app'
| 'session/audio-session-failed-to-activate' | 'session/audio-session-failed-to-activate'
export type CaptureError = export type CaptureError =
| 'capture/invalid-photo-format'
| 'capture/encoder-error'
| 'capture/muxer-error'
| 'capture/recording-in-progress' | 'capture/recording-in-progress'
| 'capture/no-recording-in-progress' | 'capture/no-recording-in-progress'
| 'capture/file-io-error' | 'capture/file-io-error'
| 'capture/create-temp-file-error' | 'capture/create-temp-file-error'
| 'capture/invalid-video-options'
| 'capture/create-recorder-error' | 'capture/create-recorder-error'
| 'capture/recorder-error' | 'capture/recorder-error'
| 'capture/no-valid-data'
| 'capture/inactive-source'
| 'capture/insufficient-storage'
| 'capture/file-size-limit-reached'
| 'capture/invalid-photo-codec'
| 'capture/not-bound-error'
| 'capture/capture-type-not-supported'
| 'capture/video-not-enabled' | 'capture/video-not-enabled'
| 'capture/photo-not-enabled' | 'capture/photo-not-enabled'
| 'capture/aborted' | 'capture/aborted'