Skip to content

Commit

Permalink
feat(narrated): global footer and related diagnostics support
Browse files Browse the repository at this point in the history
  • Loading branch information
zkat committed Sep 22, 2021
1 parent 612967d commit 3213fa6
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions src/handlers/narratable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@ impl NarratableReportHandler {
self.render_causes(f, diagnostic)?;
self.render_snippets(f, diagnostic)?;
self.render_footer(f, diagnostic)?;
self.render_related(f, diagnostic)?;
if let Some(footer) = &self.footer {
writeln!(f, "{}", footer)?;
}
Ok(())
}

Expand Down Expand Up @@ -95,6 +99,26 @@ impl NarratableReportHandler {
Ok(())
}

fn render_related(
&self,
f: &mut impl fmt::Write,
diagnostic: &(dyn Diagnostic),
) -> fmt::Result {
if let Some(related) = diagnostic.related() {
writeln!(f)?;
for rel in related {
write!(f, "Error: ")?;
self.render_header(f, rel)?;
writeln!(f)?;
self.render_causes(f, rel)?;
self.render_snippets(f, rel)?;
self.render_footer(f, rel)?;
self.render_related(f, rel)?;
}
}
Ok(())
}

fn render_snippets(
&self,
f: &mut impl fmt::Write,
Expand Down

0 comments on commit 3213fa6

Please sign in to comment.