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 {
case invalid(unionName: String, receivedValue: String)
case unsupportedOS(unionName: String, receivedValue: String, supportedOnOs: String)
case unsupportedOutput(outputDescriptor: String)
case unsupportedInput(inputDescriptor: String)
case invalidCombination(provided: String, missing: String)
@ -41,8 +40,6 @@ enum ParameterError {
switch self {
case .invalid:
return "invalid-parameter"
case .unsupportedOS:
return "unsupported-os"
case .unsupportedOutput:
return "unsupported-output"
case .unsupportedInput:
@ -56,8 +53,6 @@ enum ParameterError {
switch self {
case let .invalid(unionName: unionName, receivedValue: receivedValue):
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):
return "The output \"\(output)\" is not supported!"
case let .unsupportedInput(inputDescriptor: input):
@ -148,7 +143,6 @@ enum FormatError {
enum SessionError {
case cameraNotReady
case audioSessionSetupFailed(reason: String)
case audioSessionFailedToActivate
case audioInUseByOtherApp
@ -156,8 +150,6 @@ enum SessionError {
switch self {
case .cameraNotReady:
return "camera-not-ready"
case .audioSessionSetupFailed:
return "audio-session-setup-failed"
case .audioInUseByOtherApp:
return "audio-in-use-by-other-app"
case .audioSessionFailedToActivate:
@ -169,8 +161,6 @@ enum SessionError {
switch self {
case .cameraNotReady:
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:
return "The audio session is already in use by another app with higher priority!"
case .audioSessionFailedToActivate:
@ -182,13 +172,11 @@ enum SessionError {
// MARK: - CaptureError
enum CaptureError {
case invalidPhotoFormat
case recordingInProgress
case noRecordingInProgress
case fileError
case createTempFileError
case createRecorderError(message: String? = nil)
case invalidPhotoCodec
case videoNotEnabled
case photoNotEnabled
case aborted
@ -196,8 +184,6 @@ enum CaptureError {
var code: String {
switch self {
case .invalidPhotoFormat:
return "invalid-photo-format"
case .recordingInProgress:
return "recording-in-progress"
case .noRecordingInProgress:
@ -208,8 +194,6 @@ enum CaptureError {
return "create-temp-file-error"
case .createRecorderError:
return "create-recorder-error"
case .invalidPhotoCodec:
return "invalid-photo-codec"
case .videoNotEnabled:
return "video-not-enabled"
case .photoNotEnabled:
@ -223,10 +207,6 @@ enum CaptureError {
var message: String {
switch self {
case .invalidPhotoFormat:
return "The given photo format was invalid!"
case .invalidPhotoCodec:
return "The given photo codec was invalid!"
case .recordingInProgress:
return "There is already an active video recording in progress! Did you call startRecording() twice?"
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
enum CameraError: Error {
@ -278,7 +238,6 @@ enum CameraError: Error {
case format(_ id: FormatError)
case session(_ id: SessionError)
case capture(_ id: CaptureError)
case system(_ id: SystemError)
case unknown(message: String? = nil)
var code: String {
@ -295,8 +254,6 @@ enum CameraError: Error {
return "session/\(id.code)"
case let .capture(id: id):
return "capture/\(id.code)"
case let .system(id: id):
return "system/\(id.code)"
case .unknown:
return "unknown/unknown"
}
@ -316,8 +273,6 @@ enum CameraError: Error {
return id.message
case let .capture(id: id):
return id.message
case let .system(id: id):
return id.message
case let .unknown(message: message):
return message ?? "An unexpected error occured."
}

View File

@ -22,7 +22,8 @@ extension AVCaptureVideoStabilizationMode {
self = .cinematicExtended
return
} else {
throw EnumParserError.unsupportedOS(supportedOnOS: "iOS 13.0")
self = .cinematic
return
}
case "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.
*/
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.
*/

View File

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