1#[derive(Debug)]
5pub enum LexError {
6 UnclosedTag,
8 InvalidTag(String),
10 UnclosedValue,
12 InvalidArgumentCount { expected: usize, got: usize },
14 InvalidValue(String),
16 InvalidResetTarget,
18 UnknownStyle(String),
20}
21
22impl std::fmt::Display for LexError {
23 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
24 match self {
25 LexError::UnclosedTag => write!(f, "unclosed tag"),
26 LexError::InvalidTag(tag) => write!(f, "invalid tag: {tag}"),
27 LexError::UnclosedValue => write!(f, "unclosed parentheses for color value"),
28 LexError::InvalidArgumentCount { expected, got } => {
29 write!(f, "expected {expected} arguments, got {got}")
30 }
31 LexError::InvalidValue(s) => write!(f, "invalid value '{s}'"),
32 LexError::InvalidResetTarget => {
33 write!(f, "reset target must be a color or emphasis tag")
34 }
35 LexError::UnknownStyle(name) => {
36 write!(f, "no style named '{name}' in the registry")
37 }
38 }
39 }
40}
41
42impl std::error::Error for LexError {}