1 | use std::error::Error; |
---|---|
2 | use std::fmt::{self, Display}; |
3 | |
4 | #[derive(Debug, PartialEq)] |
5 | pub enum ParserError { |
6 | InvalidLanguage, |
7 | InvalidSubtag, |
8 | } |
9 | |
10 | impl Error for ParserError {} |
11 | |
12 | impl Display for ParserError { |
13 | fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { |
14 | let value: &str = match self { |
15 | ParserError::InvalidLanguage => "The given language subtag is invalid", |
16 | ParserError::InvalidSubtag => "Invalid subtag", |
17 | }; |
18 | f.write_str(data:value) |
19 | } |
20 | } |
21 |