vOOice/VoiceInk/Whisper/WhisperError.swift

38 lines
1.3 KiB
Swift

import Foundation
enum WhisperStateError: Error, Identifiable {
case modelLoadFailed
case transcriptionFailed
case unzipFailed
case unknownError
var id: String { UUID().uuidString }
}
extension WhisperStateError: LocalizedError {
var errorDescription: String? {
switch self {
case .modelLoadFailed:
return "Failed to load the transcription model."
case .transcriptionFailed:
return "Failed to transcribe the audio."
case .unzipFailed:
return "Failed to unzip the downloaded Core ML model."
case .unknownError:
return "An unknown error occurred."
}
}
var recoverySuggestion: String? {
switch self {
case .modelLoadFailed:
return "Try selecting a different model or redownloading the current model."
case .transcriptionFailed:
return "Check the default model try again. If the problem persists, try a different model."
case .unzipFailed:
return "The downloaded Core ML model archive might be corrupted. Try deleting the model and downloading it again. Check available disk space."
case .unknownError:
return "Please restart the application. If the problem persists, contact support."
}
}
}