1use serde_json::Value;
2use crate::operator::Operator;
3use quick_error::quick_error;
4
5
6quick_error! {
7 #[derive(Debug, PartialEq, Eq)]
9 pub enum Error {
10 UnsupportedOperator(operator: String) {
12 display("Unsupported operator: {:?}", operator)
13 }
14 CanNotExec(operator: Operator) {
16 display("This operator does not support execution: {:?}", operator)
17 }
18 StartWithNonValueOperator {
20 display("Your expression may start with non-value operator like ( + * ).")
21 }
22 UnpairedBrackets {
24 display("Unpaired brackets, left brackets count does not equal right brackets count.")
25 }
26 DuplicateValueNode {
28 display("Duplicate values node, you may have (2 3) but there is no operators between them.")
29 }
30 DuplicateOperatorNode {
32 display("Duplicate operators node, you may have (+ +) but there is no values between them.")
33 }
34 CommaNotWithFunction {
36 display("You have a comma(,) , but there is no function in front of it.")
37 }
38 BracketNotWithFunction {
40 display("You have empty brackets () , but there is no function in front of it.")
41 }
42 FunctionNotExists(ident: String) {
44 display("Function not exists: {}", ident)
45 }
46 ExpectedBoolean(value: Value) {
48 display("Expected a boolean, found: {}", value)
49 }
50 ExpectedIdentifier {
52 display("Expected ident.")
53 }
54 ExpectedArray {
56 display("Expected array.")
57 }
58 ExpectedObject {
60 display("Expected object.")
61 }
62 ExpectedNumber {
64 display("Expected number.")
65 }
66 NoFinalNode {
68 display("Failed to parse, no final expression.")
69 }
70 ArgumentsGreater(max: usize) {
72 display("The number of arguments is greater than the maximum limit: {}", max)
73 }
74 ArgumentsLess(min: usize) {
76 display("The number of arguments is less than the minimum limit: {}", min)
77 }
78 UnsupportedTypes(a: String, b: String) {
80 display("This two value types are different or do not support mathematical calculations: {}, {}", a, b)
81 }
82 InvalidRange(ident: String) {
84 display("Invalid range expression: {}", ident)
85 }
86 CanNotAddChild {
88 display("Can not add child node.")
89 }
90 Custom(detail: String) {
92 display("{}", detail)
93 }
94 }
95}