Radish alpha
h
Radicle Heartwood Protocol & Stack
Radicle
Git (anonymous pull)
Log in to clone via SSH
Ignore broken pipe in Element::print()
✗ CI failure Matthias Beyer committed 2 months ago
commit cb0c1ebf9f6aba3ce063a754464dc3f454788362
parent 423cf604e1178d62c6952f866b4b5d0b9667aca8
1 failed (1 total) View logs
1 file changed +13 -1
modified crates/radicle-term/src/element.rs
@@ -84,8 +84,20 @@ pub trait Element: fmt::Debug + Send + Sync {

    /// Print this element to stdout.
    fn print(&self) {
+
        use std::io::Write;
+

+
        let out = std::io::stdout();
+
        let mut outlock = out.lock();
+

        for line in self.render(Constraint::from_env().unwrap_or_default()) {
-
            println!("{}", line.to_string().trim_end());
+
            if let Err(error) = writeln!(outlock, "{}", line.to_string().trim_end()) {
+
                if error.kind() == std::io::ErrorKind::BrokenPipe {
+
                    // Ignore broken pipe error and simply return
+
                    break;
+
                } else {
+
                    panic!("{error}");
+
                }
+
            }
        }
    }