1use gpui::{AnyElement, App, Entity, FontWeight, Window};
2use ui::{Label, h_flex, prelude::*, v_flex};
3
4use crate::outputs::plain::TerminalOutput;
5
6/// Userspace error from the kernel
7pub struct ErrorView {
8 pub ename: String,
9 pub evalue: String,
10 pub traceback: Entity<TerminalOutput>,
11}
12
13impl ErrorView {
14 pub fn render(&self, window: &mut Window, cx: &mut App) -> Option<AnyElement> {
15 let theme = cx.theme();
16
17 let padding = window.line_height() / 2.;
18
19 Some(
20 v_flex()
21 .gap_3()
22 .child(
23 h_flex()
24 .font_buffer(cx)
25 .child(
26 Label::new(format!("{}: ", self.ename.clone()))
27 // .size(LabelSize::Large)
28 .color(Color::Error)
29 .weight(FontWeight::BOLD),
30 )
31 .child(
32 Label::new(self.evalue.clone())
33 // .size(LabelSize::Large)
34 .weight(FontWeight::BOLD),
35 ),
36 )
37 .child(
38 div()
39 .w_full()
40 .px(padding)
41 .py(padding)
42 .border_l_1()
43 .border_color(theme.status().error_border)
44 .child(self.traceback.clone()),
45 )
46 .into_any_element(),
47 )
48 }
49}