Change resolve_ast return type.
This commit is contained in:
@@ -233,22 +233,24 @@ impl ModuleResolver for FileModuleResolver {
|
||||
engine: &Engine,
|
||||
path: &str,
|
||||
pos: Position,
|
||||
) -> Result<Option<crate::AST>, Box<EvalAltResult>> {
|
||||
) -> Option<Result<crate::AST, Box<EvalAltResult>>> {
|
||||
// Construct the script file path
|
||||
let mut file_path = self.base_path.clone();
|
||||
file_path.push(path);
|
||||
file_path.set_extension(&self.extension); // Force extension
|
||||
|
||||
// Load the script file and compile it
|
||||
let mut ast = engine.compile_file(file_path).map_err(|err| match *err {
|
||||
match engine.compile_file(file_path).map_err(|err| match *err {
|
||||
EvalAltResult::ErrorSystem(_, err) if err.is::<IoError>() => {
|
||||
Box::new(EvalAltResult::ErrorModuleNotFound(path.to_string(), pos))
|
||||
}
|
||||
_ => Box::new(EvalAltResult::ErrorInModule(path.to_string(), err, pos)),
|
||||
})?;
|
||||
|
||||
ast.set_source(path);
|
||||
|
||||
Ok(Some(ast))
|
||||
}) {
|
||||
Ok(mut ast) => {
|
||||
ast.set_source(path);
|
||||
Some(Ok(ast))
|
||||
}
|
||||
err @ Err(_) => Some(err),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user