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