Skip to main content

ffcine_core/
error.rs

1use std::path::PathBuf;
2
3/// Errors from ffcine and its backends.
4#[derive(Debug, thiserror::Error)]
5#[non_exhaustive]
6pub enum Error {
7    #[error("{path}: {source}")]
8    Io {
9        path: PathBuf,
10        source: std::io::Error,
11    },
12    #[error("{path}:{line}: invalid .cube LUT: {msg}")]
13    CubeParse {
14        path: PathBuf,
15        line: usize,
16        msg: String,
17    },
18    #[error("invalid {what}: {value:?}")]
19    Invalid { what: &'static str, value: String },
20    /// A param track that doesn't parse or evaluate.
21    #[error("{path}: {msg}")]
22    Track { path: String, msg: String },
23    /// An expression that doesn't compile: the column (1-based, characters) and a caret.
24    #[error("{path}: col {col}: {msg}\n  {src}\n  {caret}^", caret = " ".repeat(col.saturating_sub(1)))]
25    Expr {
26        path: String,
27        col: usize,
28        msg: String,
29        src: String,
30    },
31    #[error("{path}: {msg}")]
32    Import { path: PathBuf, msg: String },
33    #[error("invalid OTIO JSON: {0}")]
34    Json(#[from] serde_json::Error),
35    /// The selected backend cannot run this (feature disabled, or not built yet).
36    #[error("{0} is not implemented yet")]
37    Unimplemented(&'static str),
38    /// GPU pipeline failure (device setup, libplacebo, hw frames, codecs).
39    #[error("{0}")]
40    Pipeline(String),
41    /// A GPU API call failed (CUDA, NVIDIA optical flow).
42    #[error("{api}: {msg}")]
43    Gpu { api: &'static str, msg: String },
44    #[cfg(feature = "ffmpeg")]
45    #[error("ffmpeg: {0}")]
46    Ffmpeg(#[from] ffmpeg_next::Error),
47}
48
49pub type Result<T, E = Error> = std::result::Result<T, E>;