use thiserror::Error;
pub type SpectrogramResult<T> = Result<T, SpectrogramError>;
#[derive(Debug, Error, Clone)]
#[non_exhaustive]
pub enum SpectrogramError {
#[error("Invalid input: {0}")]
InvalidInput(String),
#[error("Dimension mismatch: expected {expected}, got {got}")]
DimensionMismatch { expected: usize, got: usize },
#[error("{backend} -- FFT backend error: {msg}")]
FftBackendError { backend: &'static str, msg: String },
#[error("Internal error: {0}")]
InternalError(String),
}
impl SpectrogramError {
#[inline]
pub fn fft_backend<S: Into<String>>(backend: &'static str, msg: S) -> Self {
Self::FftBackendError {
backend,
msg: msg.into(),
}
}
#[inline]
pub fn invalid_input<S: Into<String>>(msg: S) -> Self {
Self::InvalidInput(msg.into())
}
#[inline]
#[must_use]
pub const fn dimension_mismatch(expected: usize, got: usize) -> Self {
Self::DimensionMismatch { expected, got }
}
#[inline]
pub fn internal_error<S: Into<String>>(msg: S) -> Self {
Self::InternalError(msg.into())
}
}