Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Err out better when failing to eval CEL #135

Merged
merged 1 commit into from
Nov 7, 2024
Merged

Err out better when failing to eval CEL #135

merged 1 commit into from
Nov 7, 2024

Conversation

alexsnaps
Copy link
Member

No description provided.

@@ -55,7 +55,7 @@ impl Expression {
Self::new_expression(expression, true)
}

pub fn eval(&self) -> Value {
pub fn eval(&self) -> Result<Value, String> {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the only real change really...

.all(|(pos, predicate)| match predicate.test() {
Ok(b) => b,
Err(err) => {
error!("Failed to evaluate {}: {}", self.predicates[pos], err);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

... and these are the real things that I wanted...

_ => panic!("Only scalar values can be sent as data"),
},
Err(err) => {
error!("Failed to evaluate {}: {}", cel.value, err);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

... and this ...

Err(err) => {
error!(
"Failed to evaluate {}: {}",
self.route_rule_conditions.predicates[pos], err
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

... and this.

@alexsnaps alexsnaps merged commit 8a8ee56 into main Nov 7, 2024
14 checks passed
@alexsnaps alexsnaps deleted the cel_ux_err branch November 7, 2024 15:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

3 participants