Added error propagation in Field access
@@ -8,9 +8,7 @@ impl Executable for GetConstField {
fn run(&self, interpreter: &mut Interpreter) -> ResultValue {
let mut obj = self.obj().run(interpreter)?;
if obj.get_type() != Type::Object || obj.get_type() != Type::Symbol {
- obj = interpreter
- .to_object(&obj)
- .expect("failed to convert to object");
+ obj = interpreter.to_object(&obj)?;
}
Ok(obj.get_field(self.field()))
@@ -21,9 +19,7 @@ impl Executable for GetField {
fn run(&self, interpreter: &mut Interpreter) -> ResultValue {
let mut obj = self.obj().run(interpreter)?;
if obj.get_type() != Type::Object || obj.get_type() != Type::Symbol {
- obj = interpreter
- .to_object(&obj)
- .expect("failed to convert to object");
+ obj = interpreter.to_object(&obj)?;
}
let field = self.field().run(interpreter)?;
