From 09820e5aed2768e80e9733dac040ebfe4ed1e53a Mon Sep 17 00:00:00 2001 From: ychenfo Date: Sun, 15 May 2022 02:08:00 +0800 Subject: [PATCH] nac3artiq: return err instead of panic for host object attribute error --- nac3artiq/src/lib.rs | 5 ++++- nac3artiq/src/symbol_resolver.rs | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/nac3artiq/src/lib.rs b/nac3artiq/src/lib.rs index fea0abbd..3c006350 100644 --- a/nac3artiq/src/lib.rs +++ b/nac3artiq/src/lib.rs @@ -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()); diff --git a/nac3artiq/src/symbol_resolver.rs b/nac3artiq/src/symbol_resolver.rs index ff4e715b..434a724f 100644 --- a/nac3artiq/src/symbol_resolver.rs +++ b/nac3artiq/src/symbol_resolver.rs @@ -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)? { -- 2.44.2