Skip to main content

graphitepdf_font/
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("invalid font source: {message}")]
9    InvalidFontSource { message: String },
10
11    #[error("font family not registered: {family}")]
12    UnknownFontFamily { family: String },
13
14    #[error("font style `{style}` is not registered for family `{family}`")]
15    UnknownFontStyle { family: String, style: String },
16
17    #[error("font weight `{weight}` is not registered for family `{family}` and style `{style}`")]
18    UnknownFontWeight {
19        family: String,
20        style: String,
21        weight: u16,
22    },
23
24    #[error("invalid font weight `{weight}`; expected a value between 1 and 1000")]
25    InvalidFontWeight { weight: u16 },
26
27    #[error("invalid data URI: {message}")]
28    InvalidDataUri { message: String },
29
30    #[error("unsupported remote font URL scheme `{scheme}`")]
31    UnsupportedRemoteScheme { scheme: String },
32
33    #[error("failed to load local font from `{path}`: {message}")]
34    LocalFontLoad { path: String, message: String },
35
36    #[error("failed to load remote font from `{url}`: {message}")]
37    RemoteFontLoad { url: String, message: String },
38}