1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
use std::{error, fmt, num};

/// Error that is returned if lexer fails
#[derive(Debug)]
pub enum Error {
    /// Lexer failed to process all input
    LexingIncomplete,
    /// Lexer failed for unknow reasons
    InternalError(Box<error::Error>),
}

impl fmt::Display for Error {
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        write!(f, "{}", self)
    }
}

impl error::Error for Error {}

impl From<num::ParseIntError> for Error {
    fn from(o: num::ParseIntError) -> Error {
        Error::InternalError(box o)
    }
}