Skip to main content

graphitepdf_textkit/
error.rs

1pub type Result<T> = std::result::Result<T, Error>;
2
3#[derive(Debug, thiserror::Error)]
4pub enum Error {
5    #[error(transparent)]
6    GraphitepdfErrors(#[from] graphitepdf_errors::GraphitePdfError),
7
8    #[error(transparent)]
9    Font(#[from] graphitepdf_font::Error),
10
11    #[error("text content cannot be empty")]
12    EmptyText,
13
14    #[error("font size must be positive, got {size}")]
15    InvalidFontSize { size: f32 },
16
17    #[error("text range `{start}..{end}` is invalid for content length {len}")]
18    InvalidTextRange {
19        start: usize,
20        end: usize,
21        len: usize,
22    },
23
24    #[error("text range `{start}..{end}` must align to UTF-8 boundaries")]
25    NonCharacterBoundaryRange { start: usize, end: usize },
26
27    #[error("text container must have positive dimensions, got width={width} height={height}")]
28    InvalidTextContainer { width: f32, height: f32 },
29
30    #[error("no registered or fallback font could satisfy family `{family}`")]
31    UnresolvedFont { family: String },
32}