use anyhow::Error; use cursive::views::Dialog; use cursive::views::TextView; pub fn dialog_for(e: S) -> Dialog { Dialog::around({ TextView::new(e.to_string()) }) .button("Ok", |s| { s.pop_layer(); }) } pub fn error_dialog_for(e: Error) -> Dialog { let s = e.chain() .rev() .enumerate() .map(|(i, e)| format!("{}: {}", i, e)) .fold(String::new(), |acc, s| { acc + &s + "\n" }); dialog_for(s) }