monkey_rs/parser/
error.rs

1/*!
2# Error
3
4Defines the `ParserError` type, which is used to represent errors that occur
5during parsing.
6*/
7use std::fmt;
8
9/// An error encountered while performing parsing.
10#[derive(Debug, Clone)]
11pub struct ParserError(String);
12
13impl fmt::Display for ParserError {
14    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
15        write!(f, "{}", self.0)
16    }
17}
18
19impl std::error::Error for ParserError {}
20
21impl ParserError {
22    /// Construct a new parser error with the given message to display.
23    pub fn new(msg: String) -> Self {
24        ParserError(msg)
25    }
26}