blob: 3490e302c7edafbce74ce9614e0f8f4468d3b208 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
use cursive::views::Dialog;
use cursive::views::TextView;
use anyhow::Error;
pub fn dialog_for<S: ToString>(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)
}
|