| 1 | use starlark::Error as StarlarkError; |
| 2 | use thiserror::Error; |
| 3 | |
| 4 | pub type Result<T> = std::result::Result<T, Error>; |
| 5 | |
| 6 | #[derive(Debug, Error)] |
| 7 | pub enum Error { |
| 8 | #[error("invalid decision: {0}")] |
| 9 | InvalidDecision(String), |
| 10 | #[error("invalid pattern element: {0}")] |
| 11 | InvalidPattern(String), |
| 12 | #[error("invalid example: {0}")] |
| 13 | InvalidExample(String), |
| 14 | #[error("invalid rule: {0}")] |
| 15 | InvalidRule(String), |
| 16 | #[error( |
| 17 | "expected every example to match at least one rule. rules: {rules:?}; unmatched examples: \ |
| 18 | {examples:?}" |
| 19 | )] |
| 20 | ExampleDidNotMatch { |
| 21 | rules: Vec<String>, |
| 22 | examples: Vec<String>, |
| 23 | }, |
| 24 | #[error("expected example to not match rule `{rule}`: {example}")] |
| 25 | ExampleDidMatch { rule: String, example: String }, |
| 26 | #[error("starlark error: {0}")] |
| 27 | Starlark(StarlarkError), |
| 28 | } |
| 29 |