Skip to content

Commit

Permalink
fix: Better error handling for protocol display
Browse files Browse the repository at this point in the history
  • Loading branch information
johanhelsing committed Jul 11, 2024
1 parent fd22693 commit 86b03d6
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions matchbox_protocol/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ cfg_if! {

impl fmt::Display for JsonPeerRequest {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "{}", serde_json::to_string(self).expect("error serializing message"))
write!(f, "{}", serde_json::to_string(self).map_err(|_| fmt::Error)?)
}
}
impl std::str::FromStr for JsonPeerRequest {
Expand All @@ -52,7 +52,7 @@ cfg_if! {

impl fmt::Display for JsonPeerEvent {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "{}", serde_json::to_string(self).expect("error serializing message"))
write!(f, "{}", serde_json::to_string(self).map_err(|_| fmt::Error)?)
}
}
impl std::str::FromStr for JsonPeerEvent {
Expand Down

0 comments on commit 86b03d6

Please sign in to comment.