1use std::error::Error;
2use std::fmt::Display;
3
4#[derive(Debug)]
6#[non_exhaustive]
7pub enum EvalError {
8 Unsupported,
10
11 Finished,
13
14 InvalidJs(String),
16
17 Communication(String),
19
20 Serialization(serde_json::Error),
22}
23
24impl Display for EvalError {
25 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
26 match self {
27 EvalError::Unsupported => write!(f, "EvalError::Unsupported - eval is not supported on the current platform"),
28 EvalError::Finished => write!(f, "EvalError::Finished - eval has already ran"),
29 EvalError::InvalidJs(_) => write!(f, "EvalError::InvalidJs - the provided javascript is invalid"),
30 EvalError::Communication(_) => write!(f, "EvalError::Communication - there was an error trying to communicate with between javascript and rust"),
31 EvalError::Serialization(_) => write!(f, "EvalError::Serialization - there was an error trying to serialize or deserialize the result of an eval"),
32 }
33 }
34}
35
36impl Error for EvalError {}