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