use thiserror::Error;
pub type Result<T> = std::result::Result<T, AudioFftError>;
#[derive(Error, Debug)]
pub enum AudioFftError {
#[error("Failed to read audio file: {0}")]
FileReadError(String),
#[error("Failed to write audio file: {0}")]
FileWriteError(String),
#[error("Invalid audio format: {0}")]
InvalidFormat(String),
#[error("FFT processing error: {0}")]
FftError(String),
#[error("Audio device error: {0}")]
DeviceError(String),
#[error("K2K messaging error: {0}")]
K2KError(String),
#[error("Kernel error: {0}")]
KernelError(String),
#[error("Configuration error: {0}")]
ConfigError(String),
#[error("Buffer {0}")]
BufferError(String),
#[error("Processing timeout: {0}")]
Timeout(String),
#[error("RingKernel error: {0}")]
RingKernelError(#[from] ringkernel_core::error::RingKernelError),
#[error("IO error: {0}")]
IoError(#[from] std::io::Error),
}
impl AudioFftError {
pub fn file_read(msg: impl Into<String>) -> Self {
Self::FileReadError(msg.into())
}
pub fn file_write(msg: impl Into<String>) -> Self {
Self::FileWriteError(msg.into())
}
pub fn invalid_format(msg: impl Into<String>) -> Self {
Self::InvalidFormat(msg.into())
}
pub fn fft(msg: impl Into<String>) -> Self {
Self::FftError(msg.into())
}
pub fn device(msg: impl Into<String>) -> Self {
Self::DeviceError(msg.into())
}
pub fn k2k(msg: impl Into<String>) -> Self {
Self::K2KError(msg.into())
}
pub fn kernel(msg: impl Into<String>) -> Self {
Self::KernelError(msg.into())
}
pub fn config(msg: impl Into<String>) -> Self {
Self::ConfigError(msg.into())
}
pub fn buffer(msg: impl Into<String>) -> Self {
Self::BufferError(msg.into())
}
pub fn timeout(msg: impl Into<String>) -> Self {
Self::Timeout(msg.into())
}
}