| 1 | use thiserror::Error; |
| 2 | |
| 3 | /// CAS error types |
| 4 | #[derive(Debug, Error)] |
| 5 | pub enum CasError { |
| 6 | #[error("Parse error at position {position}: {message}")] |
| 7 | Parse { position: usize, message: String }, |
| 8 | |
| 9 | #[error("Undefined variable: {0}")] |
| 10 | UndefinedVariable(String), |
| 11 | |
| 12 | #[error("Undefined function: {0}")] |
| 13 | UndefinedFunction(String), |
| 14 | |
| 15 | #[error("Type error: {0}")] |
| 16 | Type(String), |
| 17 | |
| 18 | #[error("Division by zero")] |
| 19 | DivisionByZero, |
| 20 | |
| 21 | #[error("Domain error: {0}")] |
| 22 | Domain(String), |
| 23 | |
| 24 | #[error("Not implemented: {0}")] |
| 25 | NotImplemented(String), |
| 26 | |
| 27 | #[error("Invalid argument: {0}")] |
| 28 | InvalidArgument(String), |
| 29 | |
| 30 | #[error("Evaluation error: {0}")] |
| 31 | EvaluationError(String), |
| 32 | } |
| 33 | |
| 34 | pub type Result<T> = std::result::Result<T, CasError>; |
| 35 |