chiark / gitweb /
More robust handling of fatal errors in sync_channel.
authorSimon Tatham <anakin@pobox.com>
Fri, 5 Jan 2024 09:48:58 +0000 (09:48 +0000)
committerSimon Tatham <anakin@pobox.com>
Fri, 5 Jan 2024 09:57:51 +0000 (09:57 +0000)
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.

src/tui.rs

index 56ed67a21aa2310dd4133fbd2518ee87a2e449c5..9b6bab9f88e0696207c05a383d8ec9bc0a1c361d 100644 (file)
@@ -188,6 +188,13 @@ impl From<ClientError> for TuiError {
         }
     }
 }
+impl From<std::sync::mpsc::RecvError> 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) => {