pjson_parser/parser/
errors.rs1use std::error::Error;
2use std::fmt;
3
4#[derive(Debug)]
7pub enum ParserError {
8 UnexpectedCharacterError(char, usize),
9 UnexpectedNumberError(usize),
10 UnexpectedEndError,
11}
12
13impl Error for ParserError {}
14
15impl fmt::Display for ParserError {
16 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
17 match *self {
18 ParserError::UnexpectedCharacterError(c, p) => {
19 write!(f, "Unexpected character {} at position {}", c, p)
20 }
21 ParserError::UnexpectedNumberError(p) => write!(f, "Unexpected number at position {}", p),
22 ParserError::UnexpectedEndError => write!(f, "Unexpected end of JSON input"),
23 }
24 }
25}