pub use crate::audio::AudioError;
pub use crate::provider::ProviderError;
#[derive(Debug, thiserror::Error)]
pub enum WhisError {
#[error("Audio error: {0}")]
Audio(#[from] AudioError),
#[error("Provider error: {0}")]
Provider(#[from] ProviderError),
#[error("Configuration error: {0}")]
Config(String),
#[error("Model error: {0}")]
Model(String),
#[error("Settings error: {0}")]
Settings(String),
#[error("I/O error: {0}")]
Io(#[from] std::io::Error),
#[error("{0}")]
Other(String),
}
impl WhisError {
pub fn config(msg: impl Into<String>) -> Self {
Self::Config(msg.into())
}
pub fn model(msg: impl Into<String>) -> Self {
Self::Model(msg.into())
}
pub fn settings(msg: impl Into<String>) -> Self {
Self::Settings(msg.into())
}
pub fn other(msg: impl Into<String>) -> Self {
Self::Other(msg.into())
}
}
pub type Result<T> = std::result::Result<T, WhisError>;
impl From<anyhow::Error> for WhisError {
fn from(err: anyhow::Error) -> Self {
WhisError::Other(err.to_string())
}
}