Skip to main content

hayro_postscript/
error.rs

1//! Error types for the PostScript scanner.
2
3use core::fmt;
4
5/// A specialized [`Result`] type for PostScript scanner operations.
6pub type Result<T> = core::result::Result<T, Error>;
7
8/// An error encountered while scanning a PostScript token stream.
9#[derive(Debug, Clone, PartialEq, Eq)]
10pub enum Error {
11    /// A syntax error in the input.
12    SyntaxError,
13    /// A numeric value exceeded implementation limits.
14    LimitCheck,
15    /// An unsupported PostScript type was encountered (like dictionaries or
16    /// procedures, which will be added in the future).
17    UnsupportedType,
18}
19
20impl fmt::Display for Error {
21    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
22        match self {
23            Self::SyntaxError => f.write_str("syntaxerror"),
24            Self::LimitCheck => f.write_str("limitcheck"),
25            Self::UnsupportedType => f.write_str("unsupported type"),
26        }
27    }
28}
29
30impl core::error::Error for Error {}