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 #[error("Embedding Error: {0}")]
22 EmbeddingError(#[from] ort::Error),
23 #[error("Send Error")]
24 SendError,
25 #[error("Access Error when accessing thread-local model: {0}")]
26 AccessError(#[from] std::thread::AccessError),
27}
28
29pub type AnalysisResult<T> = Result<T, AnalysisError>;
30
31#[derive(Error, Debug)]
32pub enum ClusteringError {
33 #[error("Library too small to cluster")]
34 SmallLibrary,
35 #[error("Optimal k could not be found below k={0}")]
36 OptimalKNotFound(usize),
37 #[error("Failed to project data {0}")]
38 ProjectionError(#[from] ProjectionError),
39}
40
41#[derive(Error, Debug)]
42pub enum ProjectionError {
43 #[error("with T-SNE: {0}")]
44 TSneError(#[from] linfa_tsne::TSneError),
45 #[error("with PCA: {0}")]
46 PcaError(#[from] linfa_reduction::ReductionError),
47}