| 1 |
use ariadne::{Color, Config, Label, Report, ReportKind, Source}; |
| 2 |
|
| 3 |
fn main() { |
| 4 |
Report::build(ReportKind::Error, 34..34) |
| 5 |
.with_message("Incompatible types") |
| 6 |
.with_label(Label::new(32..33).with_message("This is of type Nat")) |
| 7 |
.with_label(Label::new(42..45).with_message("This is of type Str")) |
| 8 |
.finish() |
| 9 |
.print(Source::from(include_str!("sample.tao"))) |
| 10 |
.unwrap(); |
| 11 |
|
| 12 |
const SOURCE: &str = "a b c d e f"; |
| 13 |
// also supports labels with no messages to only emphasis on some areas |
| 14 |
Report::build(ReportKind::Error, 2..3) |
| 15 |
.with_message("Incompatible types") |
| 16 |
.with_config(Config::default().with_compact(true)) |
| 17 |
.with_label(Label::new(0..1).with_color(Color::Red)) |
| 18 |
.with_label( |
| 19 |
Label::new(2..3) |
| 20 |
.with_color(Color::Blue) |
| 21 |
.with_message("`b` for banana") |
| 22 |
.with_order(1), |
| 23 |
) |
| 24 |
.with_label(Label::new(4..5).with_color(Color::Green)) |
| 25 |
.with_label( |
| 26 |
Label::new(7..9) |
| 27 |
.with_color(Color::Cyan) |
| 28 |
.with_message("`e` for emerald"), |
| 29 |
) |
| 30 |
.finish() |
| 31 |
.print(Source::from(SOURCE)) |
| 32 |
.unwrap(); |
| 33 |
} |