Skip to content

Commit

Permalink
chore(execution-engine) This commit adds a dedicated triplet resoluti…
Browse files Browse the repository at this point in the history
…on error for call (#500)
  • Loading branch information
raftedproc committed Mar 7, 2023
1 parent b934efc commit 56d3ab2
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
7 changes: 7 additions & 0 deletions air/src/execution_step/errors/catchable_errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,13 @@ pub enum CatchableError {
/// This error type is occurred when the length functor applied to a value of non-array type.
#[error("the length functor could applied only to an array-like value, but it's applied to '{0}'")]
LengthFunctorAppliedToNotArray(JValue),

/// Call gets non-string JValue resolving triplet parts.
#[error("call cannot resolve non-String triplet variable part `{variable_name}` with value '{actual_value}'")]
NonStringValueInTripletResolution {
variable_name: String,
actual_value: JValue,
},
}

impl From<LambdaError> for Rc<CatchableError> {
Expand Down
3 changes: 1 addition & 2 deletions air/src/execution_step/instructions/call/triplet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,9 @@ pub(crate) fn resolve_to_string<'i>(
fn try_jvalue_to_string(jvalue: JValue, variable_name: impl Into<String>) -> ExecutionResult<String> {
match jvalue {
JValue::String(s) => Ok(s),
_ => Err(CatchableError::IncompatibleJValueType {
_ => Err(CatchableError::NonStringValueInTripletResolution {
variable_name: variable_name.into(),
actual_value: jvalue,
expected_value_type: "string",
}
.into()),
}
Expand Down
2 changes: 1 addition & 1 deletion air/tests/test_module/features/errors/last_error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ fn variable_names_shown_in_error() {
assert_eq!(
trace[1.into()],
executed_state::scalar(json!(
"expected JValue type 'string' for the variable `-relay-`, but got '1'"
"call cannot resolve non-String triplet variable part `-relay-` with value '1'"
))
);
}
Expand Down

0 comments on commit 56d3ab2

Please sign in to comment.