Wrap file module functions in ErrorInModule.

This commit is contained in:
Stephen Chung
2020-09-25 20:24:03 +08:00
parent 39bbff878c
commit da9aa60256
3 changed files with 22 additions and 9 deletions

View File

@@ -1280,13 +1280,22 @@ impl Module {
name,
num_args,
move |engine: &Engine, _, args: &mut [&mut Dynamic]| {
engine.call_fn_dynamic_raw(
&mut Scope::new(),
&ast_lib,
&fn_name,
&mut None,
args,
)
engine
.call_fn_dynamic_raw(
&mut Scope::new(),
&ast_lib,
&fn_name,
&mut None,
args,
)
.map_err(|err| {
// Wrap the error in a module-error
Box::new(EvalAltResult::ErrorInModule(
"".to_string(),
err,
Position::none(),
))
})
},
);
}