Skip to content

Commit

Permalink
Changed panics in deserialize to errors.
Browse files Browse the repository at this point in the history
Made them more descriptive
  • Loading branch information
jawoznia committed May 24, 2023
1 parent 0f4ca15 commit 90c2876
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions sylvia-derive/src/message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -985,10 +985,10 @@ impl<'a> GlueMessage<'a> {
let val = #sylvia ::serde_value::Value::deserialize(deserializer)?;
let map = match &val {
#sylvia ::serde_value::Value::Map(map) => map,
_ => panic!("Expected msg to be Value variant Map. Possibly an issue with msg format.")
_ => return Err(D::Error::custom("Wrong message format!"))
};
if map.len() != 1 {
panic!("Found more or zero msgs after deserialization. Expected one.")
return Err(D::Error::custom(format!("Expected exactly one message. Received {}", map.len())))
}
// Due to earlier size check of map this unwrap is safe
let recv_msg_name = map.into_iter().next().unwrap();
Expand Down

0 comments on commit 90c2876

Please sign in to comment.