Better error message for setter.

This commit is contained in:
Stephen Chung 2020-09-26 11:35:18 +08:00
parent 91886e30d2
commit e62d1cd3ff

View File

@ -288,7 +288,7 @@ impl Engine {
if let Some(prop) = extract_prop_from_getter(fn_name) { if let Some(prop) = extract_prop_from_getter(fn_name) {
return EvalAltResult::ErrorDotExpr( return EvalAltResult::ErrorDotExpr(
format!( format!(
"Unknown property '{}' for {}, or it is write-only", "Failed to get property '{}' of '{}' - the property may not exist, or it may be write-only",
prop, prop,
self.map_type_name(args[0].type_name()) self.map_type_name(args[0].type_name())
), ),
@ -301,9 +301,10 @@ impl Engine {
if let Some(prop) = extract_prop_from_setter(fn_name) { if let Some(prop) = extract_prop_from_setter(fn_name) {
return EvalAltResult::ErrorDotExpr( return EvalAltResult::ErrorDotExpr(
format!( format!(
"Unknown property '{}' for {}, or it is read-only", "Failed to set property '{}' of '{}' - the property may not exist, may be read-only, or '{}' is the wrong type",
prop, prop,
self.map_type_name(args[0].type_name()) self.map_type_name(args[0].type_name()),
self.map_type_name(args[1].type_name()),
), ),
Position::none(), Position::none(),
) )