Skip to content

Commit

Permalink
Removing panics, unimplementeds, etc from interpreter (#75)
Browse files Browse the repository at this point in the history
  • Loading branch information
clarkmcc authored Jul 22, 2024
1 parent 9a2dd72 commit dc4b65f
Show file tree
Hide file tree
Showing 2 changed files with 174 additions and 82 deletions.
26 changes: 25 additions & 1 deletion interpreter/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
extern crate core;

use cel_parser::{parse, ExpressionReferences};
use cel_parser::{parse, ExpressionReferences, Member};
use std::convert::TryFrom;
use std::sync::Arc;
use thiserror::Error;
Expand Down Expand Up @@ -62,6 +62,30 @@ pub enum ExecutionError {
/// Indicates that a comparison could not be performed.
#[error("{0:?} can not be compared to {1:?}")]
ValuesNotComparable(Value, Value),
/// Indicates that an operator was used on a type that does not support it.
#[error("Unsupported unary operator '{0}': {1:?}")]
UnsupportedUnaryOperator(&'static str, Value),
/// Indicates that an unsupported binary operator was applied on two values
/// where it's unsupported, for example list + map.
#[error("Unsupported binary operator '{0}': {1:?}, {2:?}")]
UnsupportedBinaryOperator(&'static str, Value, Value),
/// Indicates that an unsupported type was used to index a map
#[error("Cannot use value as map index: {0:?}")]
UnsupportedMapIndex(Value),
/// Indicates that an unsupported type was used to index a list
#[error("Cannot use value as list index: {0:?}")]
UnsupportedListIndex(Value),
/// Indicates that an unsupported type was used to index a list
#[error("Cannot use value {0:?} to index {1:?}")]
UnsupportedIndex(Value, Value),
/// Indicates that a function call occurred without an [`Expression::Ident`]
/// as the function identifier.
#[error("Unsupported function call identifier type: {0:?}")]
UnsupportedFunctionCallIdentifierType(Expression),
/// Indicates that a [`Member::Fields`] construction was attempted
/// which is not yet supported.
#[error("Unsupported fields construction: {0:?}")]
UnsupportedFieldsConstruction(Member),
/// Indicates that a function had an error during execution.
#[error("Error executing function '{function}': {message}")]
FunctionError { function: String, message: String },
Expand Down
Loading

0 comments on commit dc4b65f

Please sign in to comment.