diff --git a/crates/collab/src/rpc.rs b/crates/collab/src/rpc.rs index 9c00c930c9..e839f81772 100644 --- a/crates/collab/src/rpc.rs +++ b/crates/collab/src/rpc.rs @@ -47,7 +47,6 @@ use tokio::{ }; use tower::ServiceBuilder; use tracing::{info_span, instrument, Instrument}; -use util::ResultExt; type MessageHandler = Box, Box) -> BoxFuture<'static, ()>>; @@ -875,7 +874,7 @@ impl Server { contacts: contacts.clone(), }, ) - .log_err(); + .trace_err(); } } } @@ -1110,13 +1109,14 @@ impl Executor for RealExecutor { } } +#[instrument(skip(f))] fn broadcast(sender_id: ConnectionId, receiver_ids: Vec, mut f: F) where F: FnMut(ConnectionId) -> anyhow::Result<()>, { for receiver_id in receiver_ids { if receiver_id != sender_id { - f(receiver_id).log_err(); + f(receiver_id).trace_err(); } } } @@ -1217,6 +1217,29 @@ fn to_tungstenite_message(message: AxumMessage) -> TungsteniteMessage { } } +pub trait ResultExt { + type Ok; + + fn trace_err(self) -> Option; +} + +impl ResultExt for Result +where + E: std::fmt::Debug, +{ + type Ok = T; + + fn trace_err(self) -> Option { + match self { + Ok(value) => Some(value), + Err(error) => { + tracing::error!("{:?}", error); + None + } + } + } +} + #[cfg(test)] mod tests { use super::*;