mecomp_analysis/
errors.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
use thiserror::Error;

#[derive(Error, Debug)]
pub enum AnalysisError {
    #[error("Failed to open file: {0}")]
    FileOpenError(#[from] std::io::Error),
    #[error("Failed to decode audio: {0}")]
    DecodeError(#[from] rodio::decoder::DecoderError),
    #[error("Failed to resample audio: {0}")]
    ResampleError(#[from] rubato::ResampleError),
    #[error("Failed to create resampler: {0}")]
    ResamplerConstructionError(#[from] rubato::ResamplerConstructionError),
    #[error("Failure During Analysis: {0}")]
    AnalysisError(String),
    #[error("Samples are empty or too short")]
    EmptySamples,
    #[error("Audio Source length is unknown or infinite")]
    InfiniteAudioSource,
    #[error("Too many or too little features were provided at the end of the analysis")]
    InvalidFeaturesLen,
}

pub type AnalysisResult<T> = Result<T, AnalysisError>;

#[derive(Error, Debug)]
pub enum ClusteringError {
    #[error("Library too small to cluster")]
    SmallLibrary,
    #[error("Optimal k could not be found below k={0}")]
    OptimalKNotFound(usize),
    #[error("Failed to project data: {0}")]
    ProjectionError(#[from] linfa_tsne::TSneError),
}