typst_bake/
error.rs

1//! Error types for typst-bake
2
3use thiserror::Error;
4
5/// Errors that can occur during document compilation and rendering.
6#[derive(Error, Debug)]
7pub enum Error {
8    /// Entry file was not found in the embedded templates.
9    #[error("entry file not found: {0}")]
10    EntryNotFound(String),
11
12    /// Entry file content is not valid UTF-8.
13    #[error("entry file is not valid UTF-8")]
14    InvalidUtf8,
15
16    /// Typst compilation failed.
17    #[error("compilation failed:\n{0}")]
18    Compilation(String),
19
20    /// PDF generation failed.
21    #[error("PDF generation failed: {0}")]
22    PdfGeneration(String),
23
24    /// PNG encoding failed.
25    #[error("PNG encoding failed: {0}")]
26    PngEncoding(String),
27
28    /// Decompression of embedded content failed.
29    #[error("decompression failed")]
30    Decompression(#[from] std::io::Error),
31}
32
33/// A specialized Result type for typst-bake operations.
34pub type Result<T> = std::result::Result<T, Error>;