Wrap file module functions in ErrorInModule.
This commit is contained in:
@@ -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(),
|
||||
))
|
||||
})
|
||||
},
|
||||
);
|
||||
}
|
||||
|
@@ -182,9 +182,12 @@ impl fmt::Display for EvalAltResult {
|
||||
Self::ErrorParsing(p, _) => write!(f, "Syntax error: {}", p)?,
|
||||
|
||||
Self::ErrorInFunctionCall(s, err, _) => {
|
||||
write!(f, "Error in call to function '{}' : {}", s, err)?
|
||||
write!(f, "Error in call to function '{}': {}", s, err)?
|
||||
}
|
||||
Self::ErrorInModule(s, err, _) => write!(f, "Error in module '{}' : {}", s, err)?,
|
||||
Self::ErrorInModule(s, err, _) if s.is_empty() => {
|
||||
write!(f, "Error in module: {}", err)?
|
||||
}
|
||||
Self::ErrorInModule(s, err, _) => write!(f, "Error in module '{}': {}", s, err)?,
|
||||
|
||||
Self::ErrorFunctionNotFound(s, _)
|
||||
| Self::ErrorVariableNotFound(s, _)
|
||||
|
Reference in New Issue
Block a user