spectral_prosody/
error.rs1use std::fmt;
2
3#[derive(Debug, Clone)]
5pub enum ProsodyError {
6 InsufficientNodes { got: usize, need: usize },
8 DecompositionFailed(String),
10 InvalidParameter(String),
12 EmptyFeature,
14 IndexOutOfRange { index: usize, len: usize },
16}
17
18impl fmt::Display for ProsodyError {
19 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
20 match self {
21 Self::InsufficientNodes { got, need } => {
22 write!(f, "need at least {need} nodes, got {got}")
23 }
24 Self::DecompositionFailed(msg) => write!(f, "decomposition failed: {msg}"),
25 Self::InvalidParameter(msg) => write!(f, "invalid parameter: {msg}"),
26 Self::EmptyFeature => write!(f, "feature vector is empty"),
27 Self::IndexOutOfRange { index, len } => {
28 write!(f, "index {index} out of range (len={len})")
29 }
30 }
31 }
32}
33
34impl std::error::Error for ProsodyError {}