Better error handling messages.

This commit is contained in:
Stephen Chung 2020-09-28 11:19:49 +08:00
parent a1cf852bb9
commit 5e43f2e5a4
2 changed files with 9 additions and 4 deletions

View File

@ -643,7 +643,7 @@ impl Dynamic {
}; };
#[cfg(feature = "no_closure")] #[cfg(feature = "no_closure")]
panic!("'no_closure' feature does not support converting into a shared value"); panic!("converting into a shared value is not supported under 'no_closure'");
} }
/// Convert the `Dynamic` value into specific type. /// Convert the `Dynamic` value into specific type.
@ -812,7 +812,7 @@ impl Dynamic {
self.try_cast::<T>().unwrap_or_else(|| { self.try_cast::<T>().unwrap_or_else(|| {
panic!( panic!(
"value is {} and cannot be cast to {}", "cannot cast {} value and to {}",
self_type_name, self_type_name,
type_name::<T>() type_name::<T>()
) )

View File

@ -70,8 +70,13 @@ impl ModuleResolver for ModuleResolversCollection {
pos: Position, pos: Position,
) -> Result<Module, Box<EvalAltResult>> { ) -> Result<Module, Box<EvalAltResult>> {
for resolver in self.0.iter() { for resolver in self.0.iter() {
if let Ok(module) = resolver.resolve(engine, path, pos) { match resolver.resolve(engine, path, pos) {
return Ok(module); Ok(module) => return Ok(module),
Err(err) => match *err {
EvalAltResult::ErrorModuleNotFound(_, _) => continue,
EvalAltResult::ErrorInModule(_, err, _) => return Err(err),
_ => panic!("ModuleResolver::resolve returns error that is not ErrorModuleNotFound or ErrorInModule"),
},
} }
} }