Skip to main content

crispy_media_probe/
error.rs

1//! Error types for media probing operations.
2
3/// Errors that can occur during media probing.
4#[derive(Debug, thiserror::Error)]
5pub enum ProbeError {
6    /// ffprobe binary not found in PATH.
7    #[error("ffprobe not found in PATH — install ffmpeg to use media probing")]
8    FfprobeNotFound,
9
10    /// ffmpeg binary not found in PATH.
11    #[error("ffmpeg not found in PATH — install ffmpeg to use media probing")]
12    FfmpegNotFound,
13
14    /// Process timed out.
15    #[error("operation timed out after {timeout_secs}s for {url}")]
16    Timeout {
17        /// The URL being probed.
18        url: String,
19        /// The timeout duration in seconds.
20        timeout_secs: u64,
21    },
22
23    /// Process exited with non-zero status.
24    #[error("process failed (exit code {code:?}): {stderr}")]
25    ProcessFailed {
26        /// Exit code, if available.
27        code: Option<i32>,
28        /// Standard error output.
29        stderr: String,
30    },
31
32    /// Failed to parse ffprobe JSON output.
33    #[error("failed to parse ffprobe output: {0}")]
34    JsonParse(#[from] serde_json::Error),
35
36    /// No streams found in the probed media.
37    #[error("no streams found in media at {0}")]
38    NoStreams(String),
39
40    /// I/O error during subprocess execution.
41    #[error("I/O error: {0}")]
42    Io(#[from] std::io::Error),
43
44    /// HLS playlist recursion depth exceeded.
45    #[error("HLS playlist recursion depth exceeded (max {0})")]
46    HlsMaxDepth(u32),
47
48    /// HLS playlist loop detected.
49    #[error("HLS playlist loop detected at {0}")]
50    HlsLoop(String),
51
52    /// libmpv is not available on this system.
53    #[cfg(feature = "libmpv-backend")]
54    #[error("libmpv not available: {0}")]
55    MpvUnavailable(String),
56
57    /// libmpv handle initialization failed.
58    #[cfg(feature = "libmpv-backend")]
59    #[error("libmpv initialization failed: {0}")]
60    MpvInitFailed(String),
61
62    /// An mpv command or property access failed.
63    #[cfg(feature = "libmpv-backend")]
64    #[error("mpv command '{command}' failed: {detail}")]
65    MpvCommandFailed {
66        /// The command that was attempted.
67        command: String,
68        /// Error details from mpv.
69        detail: String,
70    },
71}