1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
use std::{error, fmt};
use crate::pull_parser::Error as ParserError;
#[derive(Debug)]
#[non_exhaustive]
pub enum LoadError {
BadParser,
Parser(ParserError),
}
impl fmt::Display for LoadError {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
LoadError::BadParser => f.write_str("Attempt to use a bad parser"),
LoadError::Parser(e) => write!(f, "Parser error: {}", e),
}
}
}
impl error::Error for LoadError {
fn source(&self) -> Option<&(dyn error::Error + 'static)> {
match self {
LoadError::Parser(e) => Some(e),
_ => None,
}
}
}
impl From<ParserError> for LoadError {
fn from(e: ParserError) -> Self {
LoadError::Parser(e)
}
}