turbopack_node/render/
issue.rs

1use turbo_rcstr::rcstr;
2use turbo_tasks::{ResolvedVc, Vc};
3use turbo_tasks_fs::FileSystemPath;
4use turbopack_core::issue::{Issue, IssueStage, OptionStyledString, StyledString};
5#[turbo_tasks::value(shared)]
6#[derive(Clone)]
7pub struct RenderingIssue {
8    pub file_path: FileSystemPath,
9    pub message: ResolvedVc<StyledString>,
10    pub status: Option<i32>,
11}
12
13#[turbo_tasks::value_impl]
14impl Issue for RenderingIssue {
15    #[turbo_tasks::function]
16    fn title(&self) -> Vc<StyledString> {
17        StyledString::Text(rcstr!("Error during SSR Rendering")).cell()
18    }
19
20    #[turbo_tasks::function]
21    fn stage(&self) -> Vc<IssueStage> {
22        IssueStage::CodeGen.cell()
23    }
24
25    #[turbo_tasks::function]
26    fn file_path(&self) -> Vc<FileSystemPath> {
27        self.file_path.clone().cell()
28    }
29
30    #[turbo_tasks::function]
31    fn description(&self) -> Vc<OptionStyledString> {
32        Vc::cell(Some(self.message))
33    }
34
35    #[turbo_tasks::function]
36    fn detail(&self) -> Vc<OptionStyledString> {
37        let mut details = vec![];
38
39        if let Some(status) = self.status
40            && status != 0
41        {
42            details.push(StyledString::Text(
43                format!("Node.js exit code: {status}").into(),
44            ));
45        }
46
47        Vc::cell(Some(StyledString::Stack(details).resolved_cell()))
48    }
49
50    // TODO parse stack trace into source location
51}