summaryrefslogtreecommitdiffstats
path: root/third_party/rust/unic-langid-impl/src/parser/errors.rs
blob: acc36bff96863ca30e5e748ba1bec1c9ebc98226 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
use std::error::Error;
use std::fmt::{self, Display};

#[derive(Debug, PartialEq)]
pub enum ParserError {
    InvalidLanguage,
    InvalidSubtag,
}

impl Error for ParserError {}

impl Display for ParserError {
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        let value = match self {
            ParserError::InvalidLanguage => "The given language subtag is invalid",
            ParserError::InvalidSubtag => "Invalid subtag",
        };
        f.write_str(value)
    }
}