Err instead of panic for host object attribute error #288
|
@ -671,7 +671,10 @@ impl Nac3 {
|
|||
&mut composer.unifier,
|
||||
&self.primitive,
|
||||
);
|
||||
return Err(CompileError::new_err(msg.unwrap_or(e)));
|
||||
return Err(CompileError::new_err(format!(
|
||||
"compilation failed\n----------\n{}",
|
||||
msg.unwrap_or(e)
|
||||
)));
|
||||
}
|
||||
}
|
||||
let top_level = Arc::new(composer.make_top_level_context());
|
||||
|
|
|
@ -670,7 +670,10 @@ impl InnerResolver {
|
|||
if let TypeEnum::TFunc(..) = &*unifier.get_ty(field.1.0) {
|
||||
continue;
|
||||
} else {
|
||||
let field_data = obj.getattr(&name)?;
|
||||
let field_data = match obj.getattr(&name) {
|
||||
Ok(d) => d,
|
||||
Err(e) => return Ok(Err(format!("{}", e))),
|
||||
};
|
||||
let ty = match self
|
||||
|
||||
.get_obj_type(py, field_data, unifier, defs, primitives)?
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue
Why?
Won't other types of errors have the same issue? I don't see what's special about AttributeError. The default behavior of printing
AttributeError("...")
seems acceptable to me (for now) and should be simple enough.Here I think that it should only catch
AttributeError
because we are usinggetattr
to get the member of an object, so we are only expectingAttributeError
to happen here. Other errors should not happen.Hmm maybe it's better to use
unreachable!
to mark that internal error and panic here?