From 89ebb4a446f2416415069948d26d0b7cc54dafd1 Mon Sep 17 00:00:00 2001 From: Tim Kuehn Date: Mon, 25 Jan 2016 23:37:41 -0800 Subject: [PATCH] Don't unwrap so nonchalantly --- tarpc/src/protocol.rs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/tarpc/src/protocol.rs b/tarpc/src/protocol.rs index 3e07d39..fea4688 100644 --- a/tarpc/src/protocol.rs +++ b/tarpc/src/protocol.rs @@ -344,13 +344,13 @@ impl RpcFutures { } fn complete_reply(&mut self, id: u64, reply: Reply) { - self.0 - .as_mut() - .unwrap() - .remove(&id) - .unwrap() - .send(reply) - .unwrap(); + if let Some(tx) = self.0.as_mut().unwrap().remove(&id) { + if let Err(e) = tx.send(reply) { + warn!("Client dropped receiver for id {} before receiving reply: {}", id, e); + } + } else { + warn!("RpcFutures: expected sender for id {} but got None!", id); + } } fn set_error(&mut self, err: bincode::serde::DeserializeError) {