summaryrefslogtreecommitdiff
path: root/cli
diff options
context:
space:
mode:
authorMathias Fischler <Mafii@users.noreply.github.com>2023-06-24 14:18:21 +0200
committerGitHub <noreply@github.com>2023-06-24 14:18:21 +0200
commit2e03fb34cb9efd3f287b9658a8d84df52ad660dd (patch)
tree92c4fd41d98e8242cccf24aa1f34be0b0f020c7e /cli
parent0de7860118d0906f26accba51f4fe83e524836d8 (diff)
Add infrastructure to enrich errors with hints (#1486)
Diffstat (limited to 'cli')
-rw-r--r--cli/src/main.rs9
1 files changed, 8 insertions, 1 deletions
diff --git a/cli/src/main.rs b/cli/src/main.rs
index f8affa0d..af509a92 100644
--- a/cli/src/main.rs
+++ b/cli/src/main.rs
@@ -23,7 +23,7 @@ use std::cell::OnceCell;
use termcolor::{ColorChoice, StandardStream, WriteColor};
use typst::diag::{bail, FileError, FileResult, SourceError, StrResult};
use typst::doc::Document;
-use typst::eval::{Datetime, Library};
+use typst::eval::{eco_format, Datetime, Library};
use typst::font::{Font, FontBook, FontInfo, FontVariant};
use typst::geom::Color;
use typst::syntax::{Source, SourceId};
@@ -436,6 +436,13 @@ fn print_diagnostics(
let range = error.range(world);
let diag = Diagnostic::error()
.with_message(error.message)
+ .with_notes(
+ error
+ .hints
+ .iter()
+ .map(|e| (eco_format!("hint: {e}")).into())
+ .collect(),
+ )
.with_labels(vec![Label::primary(error.span.source(), range)]);
term::emit(&mut w, &config, world, &diag)?;