use alloc::string::String;
#[derive(Debug, Clone, PartialEq, thiserror::Error)]
#[non_exhaustive]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub enum SpectrumError {
#[error("length mismatch: xs has {xs} elements, ys has {ys}")]
LengthMismatch {
xs: usize,
ys: usize,
},
#[error("spectrum has too few samples ({0}); need ≥ 2")]
TooFewSamples(usize),
#[error("x-axis is not strictly increasing at index {index}")]
NotMonotonic {
index: usize,
},
#[error("query {x} is outside [{lo}, {hi}]")]
OutOfRange {
x: f64,
lo: f64,
hi: f64,
},
#[error("parse error: {0}")]
Parse(String),
#[error("invalid value: {what}")]
InvalidValue {
what: String,
},
}