@@ -115,7 +115,7 @@ fn augmented_value(
115115 . map ( |v| ScopeValueBuilder :: augmented_from ( v, t) )
116116 . collect :: < Result < Vec < _ > > > ( ) ?,
117117 ) ,
118- ( val, _) => panic ! ( "Value kind doesn't match the type {val_type}: {val:?}" ) ,
118+ ( val, _) => bail ! ( "Value kind doesn't match the type {val_type}: {val:?}" ) ,
119119 } ;
120120 Ok ( value)
121121}
@@ -157,18 +157,19 @@ impl<'a> ScopeEntry<'a> {
157157 fn get_local_field_schema < ' b > (
158158 schema : & ' b schema:: StructSchema ,
159159 indices : & [ u32 ] ,
160- ) -> & ' b schema:: FieldSchema {
160+ ) -> Result < & ' b schema:: FieldSchema > {
161161 let field_idx = indices[ 0 ] as usize ;
162162 let field_schema = & schema. fields [ field_idx] ;
163- if indices. len ( ) == 1 {
163+ let result = if indices. len ( ) == 1 {
164164 field_schema
165165 } else {
166166 let struct_field_schema = match & field_schema. value_type . typ {
167167 schema:: ValueType :: Struct ( s) => s,
168- _ => panic ! ( "Expect struct field" ) ,
168+ _ => bail ! ( "Expect struct field" ) ,
169169 } ;
170- Self :: get_local_field_schema ( & struct_field_schema, & indices[ 1 ..] )
171- }
170+ Self :: get_local_field_schema ( & struct_field_schema, & indices[ 1 ..] ) ?
171+ } ;
172+ Ok ( result)
172173 }
173174
174175 fn get_local_key_field < ' b > (
@@ -229,8 +230,14 @@ impl<'a> ScopeEntry<'a> {
229230 }
230231 }
231232
232- fn get_field_schema ( & self , field_ref : & AnalyzedLocalFieldReference ) -> & schema:: FieldSchema {
233- Self :: get_local_field_schema ( self . schema , & field_ref. fields_idx )
233+ fn get_field_schema (
234+ & self ,
235+ field_ref : & AnalyzedLocalFieldReference ,
236+ ) -> Result < & schema:: FieldSchema > {
237+ Ok ( Self :: get_local_field_schema (
238+ self . schema ,
239+ & field_ref. fields_idx ,
240+ ) ?)
234241 }
235242
236243 fn define_field_w_builder (
@@ -329,7 +336,7 @@ async fn evaluate_op_scope(
329336 }
330337
331338 AnalyzedReactiveOp :: ForEach ( op) => {
332- let target_field_schema = head_scope. get_field_schema ( & op. local_field_ref ) ;
339+ let target_field_schema = head_scope. get_field_schema ( & op. local_field_ref ) ? ;
333340 let collection_schema = match & target_field_schema. value_type . typ {
334341 schema:: ValueType :: Collection ( cs) => cs,
335342 _ => panic ! ( "Expect target field to be a collection" ) ,
0 commit comments