chaokunyang commented on code in PR #2765:
URL: https://github.com/apache/fory/pull/2765#discussion_r2429594929
##########
rust/fory-derive/src/object/read.rs:
##########
@@ -108,16 +108,16 @@ fn gen_read_field(field: &Field, private_ident: &Ident)
-> TokenStream {
let from_any_fn = format_ident!("from_any_internal_{}",
trait_name);
let helper_mod = format_ident!("__fory_trait_helpers_{}",
trait_name);
quote! {
- let ref_flag = context.reader.read_i8();
+ let ref_flag = context.reader.read_i8()?;
if ref_flag != fory_core::types::RefFlag::NotNullValue as i8 {
- panic!("Expected NotNullValue for trait object field");
+ bail!("Expected NotNullValue for trait object field");
}
- let fory_type_id = context.reader.read_varuint32();
+ let fory_type_id = context.reader.read_varuint32()?;
let harness = fory.get_type_resolver()
.get_harness(fory_type_id)
- .expect("Type not registered for trait object field");
+ .ok_or_else(|| Error::msg("Type not registered for trait
object field"))?;
Review Comment:
this should return `TypeError`
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]