turbopack_node/render/
issue.rs

1use turbo_tasks::{ResolvedVc, Vc};
2use turbo_tasks_fs::FileSystemPath;
3use turbopack_core::issue::{Issue, IssueStage, OptionStyledString, StyledString};
4
5#[turbo_tasks::value(shared)]
6#[derive(Copy, Clone)]
7pub struct RenderingIssue {
8    pub file_path: ResolvedVc<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("Error during SSR Rendering".into()).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
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    async fn detail(&self) -> Vc<OptionStyledString> {
37        let mut details = vec![];
38
39        if let Some(status) = self.status {
40            if status != 0 {
41                details.push(StyledString::Text(
42                    format!("Node.js exit code: {status}").into(),
43                ));
44            }
45        }
46
47        Vc::cell(Some(StyledString::Stack(details).resolved_cell()))
48    }
49
50    // TODO parse stack trace into source location
51}