diff options
author | Bernd Schoolmann <mail@quexten.com> | 2023-04-27 02:14:54 +0200 |
---|---|---|
committer | Bernd Schoolmann <mail@quexten.com> | 2023-04-27 02:14:54 +0200 |
commit | d6bbc46089b519eb82ae009bd48fa6d449f07941 (patch) | |
tree | dbd2a7c6ba742163bd65e6fabd9bb64ff10c729e /src/bin | |
parent | 7729f1c13c3c19423bdc3e92f1e8cc7057667fe8 (diff) | |
download | rbw-d6bbc46089b519eb82ae009bd48fa6d449f07941.tar.gz rbw-d6bbc46089b519eb82ae009bd48fa6d449f07941.zip |
Improve error logging for websockets
Diffstat (limited to 'src/bin')
-rw-r--r-- | src/bin/rbw-agent/actions.rs | 8 | ||||
-rw-r--r-- | src/bin/rbw-agent/agent.rs | 5 | ||||
-rw-r--r-- | src/bin/rbw-agent/notifications.rs | 4 |
3 files changed, 13 insertions, 4 deletions
diff --git a/src/bin/rbw-agent/actions.rs b/src/bin/rbw-agent/actions.rs index 5ee23d9..f5b9dc0 100644 --- a/src/bin/rbw-agent/actions.rs +++ b/src/bin/rbw-agent/actions.rs @@ -1,3 +1,5 @@ +use std::f32::consts::E; + use anyhow::Context as _; pub async fn register( @@ -205,7 +207,11 @@ pub async fn login( } } - let _ = subscribe_to_notifications(state.clone()).await; + let err = subscribe_to_notifications(state.clone()).await.err(); + if let Some(e) = err { + eprintln!("failed to subscribe to notifications: {}", e) + } + respond_ack(sock).await?; diff --git a/src/bin/rbw-agent/agent.rs b/src/bin/rbw-agent/agent.rs index 0d672ee..fb21728 100644 --- a/src/bin/rbw-agent/agent.rs +++ b/src/bin/rbw-agent/agent.rs @@ -78,7 +78,10 @@ impl Agent { self, listener: tokio::net::UnixListener, ) -> anyhow::Result<()> { - let _ = crate::actions::subscribe_to_notifications(self.state.clone()).await; + let err = crate::actions::subscribe_to_notifications(self.state.clone()).await; + if let Err(e) = err { + eprintln!("failed to subscribe to notifications: {e:#}") + } enum Event { Request(std::io::Result<tokio::net::UnixStream>), diff --git a/src/bin/rbw-agent/notifications.rs b/src/bin/rbw-agent/notifications.rs index 334466f..b575cf9 100644 --- a/src/bin/rbw-agent/notifications.rs +++ b/src/bin/rbw-agent/notifications.rs @@ -125,13 +125,13 @@ async fn subscribe_to_notifications(url: String, sending_channels: std::sync::Ar for channel in a.iter() { let res = channel.send(msg); if res.is_err() { - println!("error sending websocket message to channel"); + eprintln!("error sending websocket message to channel"); } } } }, Err(e) => { - println!("websocket error: {:?}", e); + eprintln!("websocket error: {:?}", e); }, _ => {} } |