diff --git a/src/message.rs b/src/message.rs index 2f02f15..f852aa7 100644 --- a/src/message.rs +++ b/src/message.rs @@ -55,11 +55,22 @@ impl Message { pub fn send_error( socket: &UdpSocket, code: ErrorCode, - msg: String, + msg: &str, ) -> Result<(), Box> { - socket.send(&Packet::Error { code, msg }.serialize()?)?; + if socket + .send( + &Packet::Error { + code, + msg: msg.to_string(), + } + .serialize()?, + ) + .is_err() + { + eprintln!("could not send an error message"); + }; - Ok(()) + Err(msg.into()) } /// Sends an error packet to the supplied [`SocketAddr`]. diff --git a/src/worker.rs b/src/worker.rs index 812c0ca..4e4f730 100644 --- a/src/worker.rs +++ b/src/worker.rs @@ -231,7 +231,7 @@ fn check_response(socket: &UdpSocket) -> Result<(), Box> { Message::send_error( &socket, ErrorCode::IllegalOperation, - "invalid oack response".to_string(), + "invalid oack response", )?; } }