resolver/error/
mod.rs

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