1use thiserror::Error;
2#[cfg(feature = "typst-lib")]
3use typst::{diag::SourceDiagnostic, ecow::EcoVec};
4
5#[derive(Debug, Error)]
6pub enum Error {
7 #[cfg(feature = "typst-lib")]
8 #[error("Typst compilation failed: {0:?}")]
9 TypstCompilation(EcoVec<SourceDiagnostic>),
10
11 #[cfg(feature = "typst-bin")]
12 #[error("Typst binary compilation failed: {0}")]
13 TypstBinary(String),
14
15 #[error("No pages in the document")]
16 NoPages,
17
18 #[error("Failed to create ndarray from shape: {0}")]
19 NDArrayShape(#[from] ndarray::ShapeError),
20
21 #[cfg(feature = "embedded-ffmpeg")]
22 #[error("Video encoding failed: {0}")]
23 VideoEncoding(#[from] rsmpeg::error::RsmpegError),
24
25 #[cfg(feature = "ffmpeg-bin")]
26 #[error("FFmpeg binary error: {0}")]
27 FFmpegBinary(#[from] anyhow::Error),
28
29 #[error("I/O error: {0}")]
30 Io(#[from] std::io::Error),
31
32 #[error("Failed to send frame to encoder thread")]
33 FrameSendError,
34
35 #[error("Rendering or encoding failed")]
36 RenderOrEncode,
37
38 #[error("Failed to send task to worker thread")]
39 TaskSendError,
40
41 #[error("A thread panicked: {0}")]
42 ThreadPanic(String),
43
44 #[error("Failed to create pixmap for resizing")]
45 PixmapCreation,
46
47 #[error("Failed to create temp file for video encoding")]
48 TempFileCreation(#[source] std::io::Error),
49
50 #[error("Failed to merge video chunks: {0}")]
51 MergeVideoChunks(String),
52
53 #[error("Failed to create sws context")]
54 SwsContextCreation,
55}
56
57pub type Result<T> = std::result::Result<T, Error>;