|
1 | 1 | pub type CelParserResult<T = ()> = Result<T, CelParserError>; |
2 | 2 |
|
| 3 | +/// CEL expression parsing error. |
3 | 4 | #[derive(thiserror::Error, Debug)] |
4 | 5 | pub enum CelParserError { |
| 6 | + /// The CEL parser encountered an unsupported CEL function. |
5 | 7 | #[error(r#""{0}" is not a supported CEL function, only default_certification is currently supported"#)] |
6 | 8 | UnrecognizedFunction(String), |
7 | 9 |
|
| 10 | + /// The CEL parser expected a parameter at a position, but none was found. |
8 | 11 | #[error(r#"Parameter at position {parameter_position:?} for function {function_name:?} is missing, expected {parameter_name:?} with type {parameter_type:?}"#)] |
9 | 12 | MissingFunctionParameter { |
| 13 | + /// The name of the function with a missing parameter. |
10 | 14 | function_name: String, |
| 15 | + /// The expected type of the missing parameter. |
11 | 16 | parameter_type: String, |
| 17 | + /// The expected name of the missing parameter. |
12 | 18 | parameter_name: String, |
| 19 | + /// The expected position of the missing parameter. |
13 | 20 | parameter_position: u8, |
14 | 21 | }, |
15 | 22 |
|
| 23 | + /// The CEL parser expected a parameter to have a different type than the one it found. |
16 | 24 | #[error(r#"Parameter at position {parameter_position:?} for function {function_name:?} has the wrong type, expected {parameter_name:?} {expected_parameter_type:?} found {found_parameter_type:?}"#)] |
17 | 25 | IncorrectFunctionParameterType { |
| 26 | + /// The name of the function with an unexpected parameter type. |
18 | 27 | function_name: String, |
| 28 | + /// The name of the parameter with the unexpected type. |
19 | 29 | parameter_name: String, |
| 30 | + /// The expected type of the parameter. |
20 | 31 | expected_parameter_type: String, |
| 32 | + /// The actual type of the parameter. |
21 | 33 | found_parameter_type: String, |
| 34 | + /// The position of the parameter. |
22 | 35 | parameter_position: u8, |
23 | 36 | }, |
24 | 37 |
|
| 38 | + /// The CEL parser expected a node to have a different type than the one it found. |
25 | 39 | #[error(r#"Expected node with name {node_name:?} to have type {expected_type:?}, found {found_type:?}"#)] |
26 | 40 | UnexpectedNodeType { |
| 41 | + /// The name of the node with an unexpected type. |
27 | 42 | node_name: String, |
| 43 | + /// The expected type of the node. |
28 | 44 | expected_type: String, |
| 45 | + /// The actual type of the node. |
29 | 46 | found_type: String, |
30 | 47 | }, |
31 | 48 |
|
| 49 | + /// The CEL parser expected a node to have a different name than the one it found. |
32 | 50 | #[error(r#"Expected node with type {node_type:?} to have name {expected_name:?}, found {found_name:?}"#)] |
33 | 51 | UnexpectedNodeName { |
| 52 | + /// The type of the node with an unexpected name. |
34 | 53 | node_type: String, |
| 54 | + /// The expected name of the node. |
35 | 55 | expected_name: String, |
| 56 | + /// The actual name of hte node. |
36 | 57 | found_name: String, |
37 | 58 | }, |
38 | 59 |
|
| 60 | + /// The CEL parser expected an object to have a property with a particular name, but none was found. |
39 | 61 | #[error(r#"Expected object {object_name:?} to have property {expected_property_name:?}"#)] |
40 | 62 | MissingObjectProperty { |
| 63 | + /// The name of the object with a missing property. |
41 | 64 | object_name: String, |
| 65 | + /// The expected property name. |
42 | 66 | expected_property_name: String, |
43 | 67 | }, |
44 | 68 |
|
| 69 | + /// The CEL parser encountered an extraneous property on the request certification's CEL object. |
45 | 70 | #[error(r#"The request_certification object must only specify one of the no_request_certification or request_certification properties, not both"#)] |
46 | 71 | ExtraneousRequestCertificationProperty, |
47 | 72 |
|
| 73 | + /// The CEL parser expected to find a property on the request certification's CEL object, but none was found. |
48 | 74 | #[error(r#"The request_certification object must specify at least one of the no_request_certification or request_certification properties"#)] |
49 | 75 | MissingRequestCertificationProperty, |
50 | 76 |
|
| 77 | + /// The CEL parser encountered an extraneous property on the response certification's CEL object. |
51 | 78 | #[error(r#"The response_certification object must only specify one of the certified_response_headers or response_header_exclusions properties, not both"#)] |
52 | 79 | ExtraneousResponseCertificationProperty, |
53 | 80 |
|
| 81 | + /// The CEL parser expected to find a property on the response certification's CEL object, but none was found. |
54 | 82 | #[error(r#"The response_certification object must specify at least one of the certified_response_headers or response_header_exclusions properties"#)] |
55 | 83 | MissingResponseCertificationProperty, |
56 | 84 |
|
| 85 | + /// The CEL parser encountered an extraneous property on the certification's CEL object. |
57 | 86 | #[error(r#"The ValidationArgs parameter must only specify one of the no_certification or certification properties, not both"#)] |
58 | 87 | ExtraneousValidationArgsProperty, |
59 | 88 |
|
| 89 | + /// The CEL parser expected to find a property on the certification's CEL object, but none was found. |
60 | 90 | #[error(r#"The ValidationArgs parameter must specify at least one of the no_certification or certification properties"#)] |
61 | 91 | MissingValidationArgsProperty, |
62 | 92 |
|
| 93 | + /// The CEL parser encountered a syntax error while parsing the CEL expression. Using the "debug" feature flag can help to debug these syntax errors. |
63 | 94 | #[error(r#"Cel Syntax Expception: {0}"#)] |
64 | 95 | CelSyntaxException(String), |
65 | 96 | } |
0 commit comments