Skip to content

Commit db3cf48

Browse files
committed
fix: don't drop cause-chain when rendering related errors as nested
Previously, using the show_related_errors_as_nested feature introduced in 771a075, any cause-chain of those nested errors would be dropped, so the information would get lost.
1 parent e853bbf commit db3cf48

2 files changed

Lines changed: 14 additions & 1 deletion

File tree

src/handlers/graphical.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -504,7 +504,10 @@ impl GraphicalReportHandler {
504504

505505
let mut inner_renderer = self.clone();
506506
inner_renderer.footer = None;
507-
inner_renderer.with_cause_chain = false;
507+
// Each related error is an independent diagnostic whose cause
508+
// chain has not been flattened, so keep printing it to avoid
509+
// dropping the source chain and its details.
510+
inner_renderer.with_cause_chain = true;
508511
inner_renderer.termwidth -= rest_indent.width();
509512
inner_renderer.render_report_inner(&mut inner, rel, src)?;
510513

tests/test_diagnostic_source_macro.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -345,6 +345,16 @@ fn test_display_related_errors_as_nested() {
345345
× A multi-error happened
346346
├─▶ × A multi-error happened
347347
│ ├─▶ × A nested error happened
348+
│ │ ├─▶ × TestError
349+
│ │ │
350+
│ │ ╰─▶ × A complex error happened
351+
│ │ ╭────
352+
│ │ 1 │ This is another error
353+
│ │ · ──┬─
354+
│ │ · ╰── here
355+
│ │ ╰────
356+
│ │ help: You should fix this
357+
│ │
348358
│ │ ╭────
349359
│ │ 1 │ right here
350360
│ │ · ──┬─

0 commit comments

Comments
 (0)