Skip to main content

glyphs_reader/
error.rs

1use std::{io, num::TryFromIntError, path::PathBuf};
2
3use smol_str::SmolStr;
4use thiserror::Error;
5
6use crate::{corner_components::BadCornerComponent, smart_components::BadSmartComponent};
7
8#[derive(Debug, Error)]
9#[non_exhaustive]
10pub enum Error {
11    #[error("IO failure")]
12    IoError(#[from] io::Error),
13    #[error("Unable to parse {0}: {1}")]
14    ParseError(PathBuf, String),
15    #[error("Unexpected file structure {0}")]
16    StructuralError(String),
17    #[error("No upem")]
18    NoUnitsPerEm,
19    #[error("Invalid upem")]
20    InvalidUpem(#[from] TryFromIntError),
21    #[error("Unrecognized name {0}")]
22    UnknownValueName(String),
23    #[error("Not a .glyphspackage directory: {0}")]
24    NotAGlyphsPackage(PathBuf),
25    #[error("Invalid plist")]
26    WorstPlistEver(#[from] crate::plist::Error),
27    #[error("Invalid code page {0}")]
28    InvalidCodePage(u32),
29    #[error("Invalid value: {0}")]
30    BadValue(String),
31    #[error("Bad smart component '{component}' in glyph '{glyph}': {issue}")]
32    BadSmartComponent {
33        glyph: SmolStr,
34        component: SmolStr,
35        issue: BadSmartComponent,
36    },
37    #[error("Bad corner component for glyph '{glyph}': {issue}")]
38    BadCornerComponent {
39        glyph: SmolStr,
40        issue: BadCornerComponent,
41    },
42    #[error("{value} expected to be between {lbound} and {ubound}")]
43    ProductionNameOutOfBounds {
44        value: u32,
45        lbound: u32,
46        ubound: u32,
47    },
48}