mecomp_analysis/
errors.rs1use thiserror::Error;
2
3#[derive(Error, Debug)]
4pub enum AnalysisError {
5 #[error("Failed to open file: {0}")]
6 FileOpenError(#[from] std::io::Error),
7 #[error("Failed to decode audio: {0}")]
8 DecodeError(#[from] symphonia::core::errors::Error),
9 #[error("Failed to resample audio: {0}")]
10 ResampleError(#[from] rubato::ResampleError),
11 #[error("Failed to create resampler: {0}")]
12 ResamplerConstructionError(#[from] rubato::ResamplerConstructionError),
13 #[error("Failure During Analysis: {0}")]
14 AnalysisError(String),
15 #[error("Samples are empty or too short")]
16 EmptySamples,
17 #[error("Audio Source length is unknown or infinite")]
18 IndeterminantDuration,
19 #[error("Too many or too little features were provided at the end of the analysis")]
20 InvalidFeaturesLen,
21}
22
23pub type AnalysisResult<T> = Result<T, AnalysisError>;
24
25#[derive(Error, Debug)]
26pub enum ClusteringError {
27 #[error("Library too small to cluster")]
28 SmallLibrary,
29 #[error("Optimal k could not be found below k={0}")]
30 OptimalKNotFound(usize),
31 #[error("Failed to project data {0}")]
32 ProjectionError(#[from] ProjectionError),
33}
34
35#[derive(Error, Debug)]
36pub enum ProjectionError {
37 #[error("with T-SNE: {0}")]
38 TSneError(#[from] linfa_tsne::TSneError),
39 #[error("with PCA: {0}")]
40 PcaError(#[from] linfa_reduction::ReductionError),
41}