autd3_modulation_audio_file/
error.rs1use std::num::ParseIntError;
2
3use autd3_core::{derive::ModulationError, sampling_config::SamplingConfigError};
4use thiserror::Error;
5
6#[derive(Error, Debug)]
7#[non_exhaustive]
8pub enum AudioFileError {
9 #[error("{0}")]
10 Io(#[from] std::io::Error),
11 #[error("{0}")]
12 Parse(#[from] ParseIntError),
13 #[error("{0}")]
14 Wav(#[from] hound::Error),
15 #[error("{0}")]
16 Csv(#[from] csv::Error),
17 #[error("{0}")]
18 SamplingConfig(#[from] SamplingConfigError),
19}
20
21impl From<AudioFileError> for ModulationError {
23 fn from(value: AudioFileError) -> Self {
24 ModulationError::new(value)
25 }
26}
27#[cfg(test)]
30mod tests {
31 use super::*;
32
33 #[test]
34 fn test_audio_file_error() {
35 let e = AudioFileError::Io(std::io::Error::other("test"));
36 assert_eq!(e.to_string(), "test");
37 assert_eq!(
38 format!("{:?}", e),
39 "Io(Custom { kind: Other, error: \"test\" })"
40 );
41 }
42}