Cleaned up eval error messages

This commit is contained in:
2023-07-31 16:05:48 -07:00
parent b072ff3691
commit 97b64e6bef
2 changed files with 27 additions and 84 deletions

View File

@ -11,4 +11,27 @@ pub enum EvalError {
ZeroDivision,
IncompatibleUnit,
BadDefineName
}
}
impl ToString for EvalError {
fn to_string(&self) -> String {
match self {
EvalError::BadMath => {
String::from("Failed to evaluate expression")
},
EvalError::TooBig => {
String::from("Number too big")
},
EvalError::ZeroDivision => {
String::from("Division by zero")
},
EvalError::IncompatibleUnit => {
String::from("Incompatible units")
},
EvalError::BadDefineName => {
String::from("Invalid variable name")
}
}
}
}