Make sure return is not an error.
This commit is contained in:
parent
b26ca753c2
commit
d2951bfb6b
35
src/api.rs
35
src/api.rs
@ -217,23 +217,19 @@ impl<'e> Engine<'e> {
|
|||||||
Ok(result)
|
Ok(result)
|
||||||
}
|
}
|
||||||
|
|
||||||
match eval_ast_internal(self, scope, ast) {
|
eval_ast_internal(self, scope, ast)
|
||||||
Err(EvalAltResult::Return(out, pos)) => out.downcast::<T>().map(|v| *v).map_err(|a| {
|
.or_else(|err| match err {
|
||||||
EvalAltResult::ErrorMismatchOutputType(
|
EvalAltResult::Return(out, _) => Ok(out),
|
||||||
self.map_type_name((*a).type_name()).to_string(),
|
_ => Err(err),
|
||||||
pos,
|
})
|
||||||
)
|
.and_then(|out| {
|
||||||
}),
|
out.downcast::<T>().map(|v| *v).map_err(|a| {
|
||||||
|
EvalAltResult::ErrorMismatchOutputType(
|
||||||
Ok(out) => out.downcast::<T>().map(|v| *v).map_err(|a| {
|
self.map_type_name((*a).type_name()).to_string(),
|
||||||
EvalAltResult::ErrorMismatchOutputType(
|
Position::eof(),
|
||||||
self.map_type_name((*a).type_name()).to_string(),
|
)
|
||||||
Position::eof(),
|
})
|
||||||
)
|
})
|
||||||
}),
|
|
||||||
|
|
||||||
Err(err) => Err(err),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Evaluate a file, but throw away the result and only return error (if any).
|
/// Evaluate a file, but throw away the result and only return error (if any).
|
||||||
@ -333,7 +329,10 @@ impl<'e> Engine<'e> {
|
|||||||
self.clear_functions();
|
self.clear_functions();
|
||||||
}
|
}
|
||||||
|
|
||||||
result
|
result.or_else(|err| match err {
|
||||||
|
EvalAltResult::Return(_, _) => Ok(()),
|
||||||
|
_ => Err(err),
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Load a list of functions into the Engine.
|
/// Load a list of functions into the Engine.
|
||||||
|
Loading…
Reference in New Issue
Block a user