Skip to main content

av_drift_detector/
error.rs

1use std::path::PathBuf;
2
3/// Errors returned by av-drift-detector.
4#[derive(Debug, thiserror::Error)]
5pub enum Error {
6    #[error("invalid frame rate `{0}`")]
7    InvalidFrameRate(String),
8
9    #[error("invalid time `{0}` (use seconds, `250ms`, or HH:MM:SS.mmm)")]
10    InvalidTime(String),
11
12    #[error("invalid option: {0}")]
13    InvalidOption(String),
14
15    #[error("{path}: no {kind} stream found")]
16    MissingStream { path: PathBuf, kind: &'static str },
17
18    #[error("unsupported: {0}")]
19    Unsupported(String),
20
21    #[error(
22        "could not determine the test pattern's frame rate from the video; pass it explicitly (--fps)"
23    )]
24    UnknownFrameRate,
25
26    #[error(
27        "this capture is of a test file in an older format (from av-drift 0.3 or earlier), which this \
28         version can't analyse: generate the test file again with this version, and capture it again"
29    )]
30    OldFormat,
31
32    #[error("QR code: {0}")]
33    Qr(String),
34
35    /// Running the `ffmpeg` or `ffprobe` program failed (the `ffmpeg-cli` feature).
36    #[cfg(feature = "ffmpeg-cli")]
37    #[error("{0}")]
38    FfmpegCommand(String),
39
40    #[cfg(feature = "ffmpeg")]
41    #[error("ffmpeg: {0}")]
42    Ffmpeg(#[from] ffmpeg_next::Error),
43
44    #[error(transparent)]
45    Io(#[from] std::io::Error),
46}
47
48pub type Result<T, E = Error> = std::result::Result<T, E>;