Skip to content

Commit

Permalink
Do not crash on empty terminal
Browse files Browse the repository at this point in the history
  • Loading branch information
quentinlesceller committed May 3, 2019
1 parent e673fd9 commit b76c18d
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions controller/src/display.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -409,6 +417,10 @@ pub fn accounts(acct_mappings: Vec<AcctPathMapping>) {
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();
Expand Down

0 comments on commit b76c18d

Please sign in to comment.