From fe760a257d689ab175755b4a95dc2a68d24669c3 Mon Sep 17 00:00:00 2001 From: Nickiel12 Date: Sat, 24 Aug 2024 20:11:46 +0000 Subject: [PATCH] rolled back error logging --- src/lib.rs | 55 +++++++++++++++++++++++++----------------------------- 1 file changed, 25 insertions(+), 30 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index cf0214f..b6fded3 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -86,39 +86,34 @@ pub async fn send_to_wc_task( mut sender: SplitSink>, tokio_tungstenite::tungstenite::Message> ) { info!("From app is closed: {:?}", from_app.is_closed()); - loop { - match from_app.recv().await { - Ok(msg) => { - #[cfg(debug_assertions)] - { - info!("Sending message to socket!"); - // serialized message - match serde_json::to_string(&msg) { - Err(e) => error!("Could not serialize ApplicationMessage to JSON! {e}"), - Ok(msg) => { - if let Err(e) = sender.send(Message::text(msg)).await { - error!("Could not send text ApplicationMessage to websocket! Closing websocket\n{e}"); - break; - } - } - } - - } - - #[cfg(not(debug_assertions))] - { - match bincode::serialize(&msg) { - Err(e) => error!("Could not serialize ApplicationMessage into binary! {e}"), - Ok(e) => { - if let Err(e) = sender.send(Message::binary(msg)).await { - error!("Could not send binary ApplicationMessage to websocket! Closing websocket\n{e}"); - break; - } - } + while let Ok(msg) = from_app.recv().await { + #[cfg(debug_assertions)] + { + info!("Sending message to socket!"); + // serialized message + match serde_json::to_string(&msg) { + Err(e) => error!("Could not serialize ApplicationMessage to JSON! {e}"), + Ok(msg) => { + if let Err(e) = sender.send(Message::text(msg)).await { + error!("Could not send text ApplicationMessage to websocket! Closing websocket\n{e}"); + break; + } + } + } + + } + + #[cfg(not(debug_assertions))] + { + match bincode::serialize(&msg) { + Err(e) => error!("Could not serialize ApplicationMessage into binary! {e}"), + Ok(e) => { + if let Err(e) = sender.send(Message::binary(msg)).await { + error!("Could not send binary ApplicationMessage to websocket! Closing websocket\n{e}"); + break; } } } - Err(e) => error!("Send to WC had a recv error! {e}"), } }