From b76c18d6f1f4fbb62df37e6cd6b2537b377aca9c Mon Sep 17 00:00:00 2001 From: Quentin Le Sceller Date: Fri, 3 May 2019 11:24:49 -0400 Subject: [PATCH] Do not crash on empty terminal --- controller/src/display.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/controller/src/display.rs b/controller/src/display.rs index c8944960..94a29404 100644 --- a/controller/src/display.rs +++ b/controller/src/display.rs @@ -35,6 +35,10 @@ pub fn outputs( account, cur_height ); println!(); + if term::stdout().is_none() { + println!("Could not open terminal"); + return Ok(()); + } let mut t = term::stdout().unwrap(); t.fg(term::color::MAGENTA).unwrap(); writeln!(t, "{}", title).unwrap(); @@ -132,6 +136,10 @@ pub fn txs( account, cur_height ); println!(); + if term::stdout().is_none() { + println!("Could not open terminal"); + return Ok(()); + } let mut t = term::stdout().unwrap(); t.fg(term::color::MAGENTA).unwrap(); writeln!(t, "{}", title).unwrap(); @@ -409,6 +417,10 @@ pub fn accounts(acct_mappings: Vec) { pub fn tx_messages(tx: &TxLogEntry, dark_background_color_scheme: bool) -> Result<(), Error> { let title = format!("Transaction Messages - Transaction '{}'", tx.id,); println!(); + if term::stdout().is_none() { + println!("Could not open terminal"); + return Ok(()); + } let mut t = term::stdout().unwrap(); t.fg(term::color::MAGENTA).unwrap(); writeln!(t, "{}", title).unwrap();