@@ -12,6 +12,7 @@ use bindings::{
1212 ReflectReference , ReflectionPathExt , ScriptTypeRegistration , WorldAccessGuard ,
1313 WorldCallbackAccess ,
1414} ;
15+ use error:: InteropError ;
1516use reflection_extensions:: TypeIdExtensions ;
1617
1718use crate :: namespaced_register:: NamespaceBuilder ;
@@ -101,7 +102,7 @@ fn register_world_functions(reg: &mut FunctionRegistry) -> Result<(), FunctionRe
101102 let path: ParsedPath = key. try_into ( ) . unwrap ( ) ;
102103
103104 self_. index_path ( path) ;
104- self_
105+ let r : ScriptValue = self_
105106 . with_reflect_mut ( world. clone ( ) , |r| {
106107 let target_type_id = r
107108 . get_represented_type_info ( )
@@ -112,14 +113,13 @@ fn register_world_functions(reg: &mut FunctionRegistry) -> Result<(), FunctionRe
112113 world. clone ( ) ,
113114 target_type_id,
114115 )
115- . transpose ( )
116- . unwrap ( )
117- . unwrap ( ) ;
116+ . ok_or_else ( || InteropError :: impossible_conversion ( target_type_id) ) ??;
118117
119118 r. try_apply ( other. as_partial_reflect ( ) ) . unwrap ( ) ;
120- ScriptValue :: Unit
119+ Ok :: < _ , InteropError > ( ( ) )
121120 } )
122- . unwrap ( ) ;
121+ . into ( ) ;
122+ return r;
123123 }
124124 ScriptValue :: Unit
125125 } ,
@@ -134,9 +134,9 @@ fn register_world_functions(reg: &mut FunctionRegistry) -> Result<(), FunctionRe
134134 let world = world. read ( ) . expect ( "stale world" ) ;
135135 let mut path: ParsedPath = key. try_into ( ) . unwrap ( ) ;
136136 path. convert_to_0_indexed ( ) ;
137-
138137 self_. index_path ( path) ;
139- self_
138+
139+ let r: ScriptValue = self_
140140 . with_reflect_mut ( world. clone ( ) , |r| {
141141 let target_type_id = r
142142 . get_represented_type_info ( )
@@ -147,14 +147,13 @@ fn register_world_functions(reg: &mut FunctionRegistry) -> Result<(), FunctionRe
147147 world. clone ( ) ,
148148 target_type_id,
149149 )
150- . transpose ( )
151- . unwrap ( )
152- . unwrap ( ) ;
150+ . ok_or_else ( || InteropError :: impossible_conversion ( target_type_id) ) ??;
153151
154152 r. try_apply ( other. as_partial_reflect ( ) ) . unwrap ( ) ;
155- ScriptValue :: Unit
153+ Ok :: < _ , InteropError > ( ( ) )
156154 } )
157- . unwrap ( ) ;
155+ . into ( ) ;
156+ return r;
158157 }
159158 ScriptValue :: Unit
160159 } ,
0 commit comments