-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy patherror.rs
38 lines (29 loc) · 1.22 KB
/
error.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
//! Error handling
//!
use serde_json::Value;
use thiserror;
use crate::op::NumParams;
/// Public error enumeration
#[derive(thiserror::Error, Debug)]
pub enum Error {
#[error("Invalid data - value: {value:?}, reason: {reason:?}")]
InvalidData { value: Value, reason: String },
#[error("Invalid rule - operator: '{key:?}', reason: {reason:?}")]
InvalidOperation { key: String, reason: String },
#[error("Invalid variable - '{value:?}', reason: {reason:?}")]
InvalidVariable { value: Value, reason: String },
#[error("Invalid variable key - '{value:?}', reason: {reason:?}")]
InvalidVariableKey { value: Value, reason: String },
#[error("Invalid argument for '{operation}' - '{value:?}', reason: {reason}")]
InvalidArgument {
value: Value,
operation: String,
reason: String,
},
#[error("Invalid variable mapping - {0} is not an object.")]
InvalidVarMap(Value),
#[error("Encountered an unexpected error. Please raise an issue on GitHub and include the following error message: {0}")]
UnexpectedError(String),
#[error("Wrong argument count - expected: {expected:?}, actual: {actual:?}")]
WrongArgumentCount { expected: NumParams, actual: usize },
}