|
1 | 1 | use std::sync::{Mutex, OnceLock}; |
2 | 2 | use std::{borrow::Cow, collections::BTreeMap}; |
3 | 3 |
|
4 | | -use anyhow::{bail, Ok, Result}; |
| 4 | +use anyhow::{bail, Context, Ok, Result}; |
5 | 5 | use futures::future::try_join_all; |
6 | 6 |
|
7 | 7 | use crate::builder::{plan::*, AnalyzedTransientFlow}; |
@@ -298,7 +298,17 @@ async fn evaluate_child_op_scope( |
298 | 298 | child_scope_entry: ScopeEntry<'_>, |
299 | 299 | cache: Option<&EvaluationCache>, |
300 | 300 | ) -> Result<()> { |
301 | | - evaluate_op_scope(op_scope, scoped_entries.prepend(&child_scope_entry), cache).await |
| 301 | + evaluate_op_scope(op_scope, scoped_entries.prepend(&child_scope_entry), cache) |
| 302 | + .await |
| 303 | + .with_context(|| { |
| 304 | + format!( |
| 305 | + "Evaluating in scope with key {}", |
| 306 | + match child_scope_entry.key.key() { |
| 307 | + Some(k) => k.to_string(), |
| 308 | + None => "()".to_string(), |
| 309 | + } |
| 310 | + ) |
| 311 | + }) |
302 | 312 | } |
303 | 313 |
|
304 | 314 | async fn evaluate_op_scope( |
@@ -331,15 +341,16 @@ async fn evaluate_op_scope( |
331 | 341 | let output_value = evaluate_with_cell(output_value_cell.as_ref(), move || { |
332 | 342 | op.executor.evaluate(input_values) |
333 | 343 | }) |
334 | | - .await?; |
| 344 | + .await |
| 345 | + .with_context(|| format!("Evaluating Transform op `{}`", op.name,))?; |
335 | 346 | head_scope.define_field(&op.output, &output_value)?; |
336 | 347 | } |
337 | 348 |
|
338 | 349 | AnalyzedReactiveOp::ForEach(op) => { |
339 | 350 | let target_field_schema = head_scope.get_field_schema(&op.local_field_ref)?; |
340 | 351 | let collection_schema = match &target_field_schema.value_type.typ { |
341 | 352 | schema::ValueType::Collection(cs) => cs, |
342 | | - _ => panic!("Expect target field to be a collection"), |
| 353 | + _ => bail!("Expect target field to be a collection"), |
343 | 354 | }; |
344 | 355 |
|
345 | 356 | let target_field = head_scope.get_value_field_builder(&op.local_field_ref); |
@@ -391,10 +402,12 @@ async fn evaluate_op_scope( |
391 | 402 | }) |
392 | 403 | .collect::<Vec<_>>(), |
393 | 404 | _ => { |
394 | | - panic!("Target field type is expected to be a collection"); |
| 405 | + bail!("Target field type is expected to be a collection"); |
395 | 406 | } |
396 | 407 | }; |
397 | | - try_join_all(task_futs).await?; |
| 408 | + try_join_all(task_futs) |
| 409 | + .await |
| 410 | + .with_context(|| format!("Evaluating ForEach op `{}`", op.name,))?; |
398 | 411 | } |
399 | 412 |
|
400 | 413 | AnalyzedReactiveOp::Collect(op) => { |
|
0 commit comments