ff_preview/error.rs
1//! Error types for ff-preview.
2
3use std::path::PathBuf;
4
5use thiserror::Error;
6
7/// Errors that can occur during preview and proxy operations.
8#[derive(Debug, Error)]
9pub enum PreviewError {
10 /// The media file was not found at the specified path.
11 #[error("file not found: path={path}")]
12 FileNotFound {
13 /// Path that was not found.
14 path: PathBuf,
15 },
16
17 /// The media file has no video stream.
18 #[error("no video stream found: path={path}")]
19 NoVideoStream {
20 /// Path to the media file.
21 path: PathBuf,
22 },
23
24 /// A seek operation failed.
25 #[error("seek failed: target={target:?} reason={reason}")]
26 SeekFailed {
27 /// Target timestamp of the failed seek.
28 target: std::time::Duration,
29 /// Human-readable reason for the failure.
30 reason: String,
31 },
32
33 /// An underlying decode error occurred.
34 #[error("decode failed: {0}")]
35 Decode(#[from] ff_decode::DecodeError),
36
37 /// A raw `FFmpeg` error.
38 ///
39 /// `code` is the negative integer returned by the `FFmpeg` API, or `0` when no
40 /// numeric code is available. `message` is from `av_strerror` or an internal
41 /// description.
42 #[error("ffmpeg error: {message} (code={code})")]
43 Ffmpeg {
44 /// Raw `FFmpeg` error code (negative i32). `0` when no numeric code is available.
45 code: i32,
46 /// Human-readable message from `av_strerror` or an internal description.
47 message: String,
48 },
49
50 /// A probe error while analysing the media file.
51 #[error("probe failed: {0}")]
52 Probe(#[from] ff_probe::ProbeError),
53
54 /// A proxy generation pipeline error.
55 #[cfg(feature = "proxy")]
56 #[error("pipeline failed: {0}")]
57 Pipeline(#[from] ff_pipeline::PipelineError),
58
59 /// An I/O error during file operations.
60 #[error("io error: {0}")]
61 Io(#[from] std::io::Error),
62
63 /// A seek target lies outside the valid range of the timeline.
64 #[error("seek out of range: pts={pts:?}")]
65 SeekOutOfRange {
66 /// The requested presentation timestamp that fell outside all clips.
67 pts: std::time::Duration,
68 },
69}