Skip to main content

aerosieve_decode/
error.rs

1use std::path::PathBuf;
2
3/// Errors produced while decoding, resampling, or normalizing audio.
4#[derive(Debug, thiserror::Error)]
5pub enum DecodeError {
6    /// The input file could not be opened.
7    #[error("cannot open {}: {source}", path.display())]
8    Open {
9        path: PathBuf,
10        #[source]
11        source: std::io::Error,
12    },
13
14    /// The underlying reader failed mid-stream.
15    #[error("read failed: {0}")]
16    Read(#[source] std::io::Error),
17
18    /// The container was not recognized, or no decoder exists for its codec.
19    #[error("unsupported or unrecognized audio format: {0}")]
20    UnsupportedFormat(String),
21
22    #[error("no audio track found in input")]
23    NoAudioTrack,
24
25    #[error("audio track has no declared sample rate")]
26    MissingSampleRate,
27
28    #[error("audio track declares an unsupported sample rate of {0} Hz")]
29    UnsupportedSampleRate(u32),
30
31    #[error("audio is longer than the configured limit of {limit_s} s")]
32    TooLong { limit_s: f32 },
33
34    /// An unrecoverable error was raised while decoding packets.
35    #[error("decode error: {0}")]
36    Decode(String),
37
38    #[error("resample error: {0}")]
39    Resample(String),
40
41    #[error("invalid decode config: {0}")]
42    InvalidConfig(&'static str),
43}