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