More consistent error handling in loops

This commit is contained in:
2024-08-24 10:56:05 -04:00
parent 70947d5fa7
commit ee334db157
7 changed files with 23 additions and 40 deletions

View File

@ -57,7 +57,7 @@ impl Dispatch {
pub async fn cmd_loop(&self) -> anyhow::Result<()> {
loop {
debug!("Dispatch waiting on commands");
let cmd = self.recv.recv().await?;
let cmd = self.recv.recv().await.expect("Incoming event queue failed unexpectedly");
debug!("Dispatch got command {:?}", cmd);
let cmd_type = discriminant(&cmd);
let found_listeners = self.callbacks.get(&cmd_type);
@ -65,7 +65,7 @@ impl Dispatch {
Some(listeners) => {
for listener in listeners {
trace!("Sending cmd {:?}", cmd);
listener.send(cmd.clone()).await?;
listener.send(cmd.clone()).await.expect("Outgoing event queue failed unexpectedly");
}
}
None => {debug!("Dispatch found no listeners for a command")}