From 9949c94490a45847a4255e89fff1f781b84f997e Mon Sep 17 00:00:00 2001 From: Javier Cicchelli Date: Sat, 4 Jul 2026 19:17:18 +0200 Subject: [PATCH] Extracted the error types in the Recording package target into the Errors folder. --- .../Recording/Errors/AudioCapturingError.swift | 9 +++++++++ .../Errors/AudioTranscribingError.swift | 7 +++++++ .../{Models => Errors}/RecordingError.swift | 0 .../Recording/Services/AudioCapturing.swift | 12 ------------ .../Recording/Services/AudioTranscribing.swift | 17 ++++------------- 5 files changed, 20 insertions(+), 25 deletions(-) create mode 100644 Packages/Features/Sources/Recording/Errors/AudioCapturingError.swift create mode 100644 Packages/Features/Sources/Recording/Errors/AudioTranscribingError.swift rename Packages/Features/Sources/Recording/{Models => Errors}/RecordingError.swift (100%) diff --git a/Packages/Features/Sources/Recording/Errors/AudioCapturingError.swift b/Packages/Features/Sources/Recording/Errors/AudioCapturingError.swift new file mode 100644 index 0000000..2a3add2 --- /dev/null +++ b/Packages/Features/Sources/Recording/Errors/AudioCapturingError.swift @@ -0,0 +1,9 @@ +/// The errors thrown by ``AudioCapturing``. +public enum AudioCapturingError: Error { + /// The recorder failed to start or resume the audio capture. + case captureNotStarted + /// No recording is in progress. + case noOngoingRecording + /// The user denied the app permission to record audio from the microphone. + case permissionNotGranted +} diff --git a/Packages/Features/Sources/Recording/Errors/AudioTranscribingError.swift b/Packages/Features/Sources/Recording/Errors/AudioTranscribingError.swift new file mode 100644 index 0000000..4af8c69 --- /dev/null +++ b/Packages/Features/Sources/Recording/Errors/AudioTranscribingError.swift @@ -0,0 +1,7 @@ +/// The errors thrown by ``AudioTranscribing``. +public enum AudioTranscribingError: Error { + /// The speech model assets for the locale failed to reserve, download, or install. + case assetsNotInstalled + /// The transcriber supports no equivalent of the locale the transcription was requested with. + case localeNotSupported +} diff --git a/Packages/Features/Sources/Recording/Models/RecordingError.swift b/Packages/Features/Sources/Recording/Errors/RecordingError.swift similarity index 100% rename from Packages/Features/Sources/Recording/Models/RecordingError.swift rename to Packages/Features/Sources/Recording/Errors/RecordingError.swift diff --git a/Packages/Features/Sources/Recording/Services/AudioCapturing.swift b/Packages/Features/Sources/Recording/Services/AudioCapturing.swift index 21bdba8..36c54ae 100644 --- a/Packages/Features/Sources/Recording/Services/AudioCapturing.swift +++ b/Packages/Features/Sources/Recording/Services/AudioCapturing.swift @@ -172,18 +172,6 @@ private extension AudioCapturing { } #endif -// MARK: - Errors - -/// The errors thrown by ``AudioCapturing``. -public enum AudioCapturingError: Error { - /// The recorder failed to start or resume the audio capture. - case captureNotStarted - /// No recording is in progress. - case noOngoingRecording - /// The user denied the app permission to record audio from the microphone. - case permissionNotGranted -} - // MARK: - Constants /// The constant values used across the audio recording service. diff --git a/Packages/Features/Sources/Recording/Services/AudioTranscribing.swift b/Packages/Features/Sources/Recording/Services/AudioTranscribing.swift index 383a0d7..ff6d428 100644 --- a/Packages/Features/Sources/Recording/Services/AudioTranscribing.swift +++ b/Packages/Features/Sources/Recording/Services/AudioTranscribing.swift @@ -57,9 +57,10 @@ public struct AudioTranscribing: Transcribing { let analyzer = SpeechAnalyzer(modules: [transcriber]) - async let text = transcriber.results.reduce(into: "") { text, result in - text += String(result.text.characters) - } + async let text = transcriber.results + .reduce(into: "") { text, result in + text += String(result.text.characters) + } let file = try AVAudioFile(forReading: audio) @@ -74,16 +75,6 @@ public struct AudioTranscribing: Transcribing { } -// MARK: - Errors - -/// The errors thrown by ``AudioTranscribing``. -public enum AudioTranscribingError: Error { - /// The speech model assets for the locale failed to reserve, download, or install. - case assetsNotInstalled - /// The transcriber supports no equivalent of the locale the transcription was requested with. - case localeNotSupported -} - // MARK: - Constants /// The logger that records the failures of the audio transcribing service.