use crate::constants::ExpressionEnum;
#[derive(Debug)]
pub enum Error {
Io {
message: String,
},
Invalid {
message: String,
},
UnexpectedToken {
expected: Vec<&'static str>,
got: &'static str,
},
UnexpectedSymbol {
expected: Vec<&'static str>,
got: String,
},
ArgCountMismatch {
expected: u64,
got: u64,
},
Deserialize {
path: String,
expected: &'static str,
got: String,
},
}
impl Error {
pub fn invalid(message: String) -> Self {
Error::Invalid { message }
}
pub fn unexpected_token(expected: &[&'static str], got: ExpressionEnum) -> Self {
Error::UnexpectedToken {
expected: expected.to_vec(),
got: got.name(),
}
}
}
impl From<std::io::Error> for Error {
fn from(e: std::io::Error) -> Self {
Error::Io {
message: e.to_string(),
}
}
}