1use super::parser::ParserError;
2use std::error::Error;
3use std::fmt::{self, Display};
4
5/// Enum with errors that can be returned by LanguageIdentifier.
6#[derive(Debug, PartialEq)]
7pub enum LanguageIdentifierError {
8 /// An unknown error - currently covers all-but parser errors.
9 Unknown,
10 /// A parser error.
11 ParserError(ParserError),
12}
13
14impl From<ParserError> for LanguageIdentifierError {
15 fn from(error: ParserError) -> LanguageIdentifierError {
16 LanguageIdentifierError::ParserError(error)
17 }
18}
19
20impl Error for LanguageIdentifierError {}
21
22impl Display for LanguageIdentifierError {
23 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
24 match self {
25 LanguageIdentifierError::Unknown => write!(f, "Unknown error"),
26 LanguageIdentifierError::ParserError(p: &ParserError) => write!(f, "Parser error: {}", p),
27 }
28 }
29}
30