Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changed panics in deserialize to errors. #137

Merged
merged 1 commit into from
May 25, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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