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
 7#[derive(Clone)]
 8pub struct ErrorView {
 9    pub ename: String,
10    pub evalue: String,
11    pub traceback: Entity<TerminalOutput>,
12}
13
14impl ErrorView {
15    pub fn render(&self, window: &mut Window, cx: &mut App) -> Option<AnyElement> {
16        let theme = cx.theme();
17
18        let padding = window.line_height() / 2.;
19
20        Some(
21            v_flex()
22                .gap_3()
23                .child(
24                    h_flex()
25                        .font_buffer(cx)
26                        .child(
27                            Label::new(format!("{}: ", self.ename.clone()))
28                                .color(Color::Error)
29                                .weight(FontWeight::BOLD),
30                        )
31                        .child(Label::new(self.evalue.clone()).weight(FontWeight::BOLD)),
32                )
33                .child(
34                    div()
35                        .w_full()
36                        .px(padding)
37                        .py(padding)
38                        .border_l_1()
39                        .border_color(theme.status().error_border)
40                        .child(self.traceback.clone()),
41                )
42                .into_any_element(),
43        )
44    }
45}