feat(error_report): show proeminent marking on error location

This commit is contained in:
Khaïs COLIN 2025-05-10 10:33:57 +02:00
parent 9b75cb6144
commit 620259af48
Signed by: logistic-bot
SSH key fingerprint: SHA256:3zI3/tx0ZpCLHCLPmEaGR4oeYCPMCzQxXhXutBmtOAU
2 changed files with 12 additions and 2 deletions

View file

@ -208,6 +208,8 @@ i will use rustyline, since it seems like the most feature-complete
* DONE handle non-interactive input better
* DONE show marking where error occurs
* TODO cli tests using insta-cmd
https://insta.rs/docs/cmd/

View file

@ -12,7 +12,11 @@ impl OSDBError for CommandParseError {
} else {
Report::build(ReportKind::Error, (file, 0..input.len() - 1))
.with_message(self.message())
.with_label(Label::new((file, 0..input.len() - 1)).with_color(Color::Red))
.with_label(
Label::new((file, 0..input.len() - 1))
.with_color(Color::Red)
.with_message(self.message()),
)
.finish()
.print((file, Source::from(input)))
.unwrap();
@ -25,7 +29,11 @@ impl OSDBError for ScanError {
let location = (file, Into::<std::ops::Range<usize>>::into(&self.location));
Report::build(ReportKind::Error, location.clone())
.with_message(format!("{self}"))
.with_label(Label::new(location).with_color(Color::Red))
.with_label(
Label::new(location)
.with_color(Color::Red)
.with_message(format!("{self}")),
)
.finish()
.print((file, Source::from(input)))
.unwrap();