feat(multiplexer): Add error messages to potential panics

This commit is contained in:
Santiago Carmuega 2021-12-19 17:27:48 -03:00
parent 8fe6f61a53
commit 29c16c199a
2 changed files with 7 additions and 5 deletions

View file

@ -62,7 +62,7 @@ fn read_segment(reader: &mut impl Read) -> Result<(u16, u32, Payload), std::io::
impl Bearer for TcpStream {
fn clone(&self) -> Self {
self.try_clone().unwrap()
self.try_clone().expect("error cloning tcp stream")
}
fn read_segment(&mut self) -> Result<(u16, u32, Payload), std::io::Error> {
@ -82,7 +82,7 @@ impl Bearer for TcpStream {
#[cfg(target_family = "unix")]
impl Bearer for UnixStream {
fn clone(&self) -> Self {
self.try_clone().unwrap()
self.try_clone().expect("error cloning unix stream")
}
fn read_segment(&mut self) -> Result<(u16, u32, Payload), std::io::Error> {

View file

@ -161,11 +161,13 @@ impl Multiplexer {
}
pub fn use_channel(&mut self, protocol_id: u16) -> Channel {
self.io_handles.remove(&protocol_id).unwrap()
self.io_handles
.remove(&protocol_id)
.expect("requested channel not found in multiplexer")
}
pub fn join(self) {
self.tx_thread.join().unwrap();
self.rx_thread.join().unwrap();
self.tx_thread.join().expect("error joining tx loop thread");
self.rx_thread.join().expect("error joining rx loop thread");
}
}