unicode_locale_parser/
errors.rs1use std::error::Error;
2use std::fmt::{Display, Formatter, Result};
3
4#[derive(Debug, PartialEq)]
6pub enum ParserError {
7 Missing,
9 InvalidLanguage,
11 InvalidSubtag,
13 InvalidExtension,
15 InvalidSubdivision,
17 Unexpected,
19}
20
21impl Error for ParserError {}
22
23impl Display for ParserError {
24 fn fmt(&self, f: &mut Formatter) -> Result {
25 let value = match self {
26 ParserError::Missing => "Missing identifier",
27 ParserError::InvalidLanguage => "Invalid language identifier",
28 ParserError::InvalidSubtag => "Invalid subtag",
29 ParserError::InvalidExtension => "Invalid extension",
30 ParserError::InvalidSubdivision => "Invalid subdivision",
31 ParserError::Unexpected => "Unexpected error",
32 };
33 f.write_str(value)
34 }
35}