From: Simon Tatham Date: Fri, 5 Jan 2024 09:48:58 +0000 (+0000) Subject: More robust handling of fatal errors in sync_channel. X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ian/git?a=commitdiff_plain;h=9b7f07b3b768a33c784dd7ed65a0c17fced8ae2c;p=mastodonochrome.git More robust handling of fatal errors in sync_channel. They were being squelched with a triple-FIXME comment, probably from very early in development. Now it seems clear that we just propagate them up to an 'abort the whole Tui' error, because if that goes wrong then surely there's a disaster too weird to recover from. --- diff --git a/src/tui.rs b/src/tui.rs index 56ed67a..9b6bab9 100644 --- a/src/tui.rs +++ b/src/tui.rs @@ -188,6 +188,13 @@ impl From for TuiError { } } } +impl From for TuiError { + fn from(err: std::sync::mpsc::RecvError) -> Self { + TuiError { + message: err.to_string(), + } + } +} impl std::fmt::Display for TuiError { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> @@ -335,7 +342,8 @@ impl Tui { })?; match self.subthread_receiver.recv() { - _e @ Err(_) => break Ok(()), // FIXME FIXME FIXME: not ok! + Err(e) => break 'outer Err(e.into()), + Ok(SubthreadEvent::TermEv(ev)) => { match ev { Event::Key(key) => {