anyhow/anyhow.rs
1use bel::Program;
2
3/// This example demonstrates that compilation errors can be reported with anyhow.
4fn main() {
5 if let Err(e) = evaluate() {
6 // Prints
7 //
8 // ERROR: <input>:1:3: Syntax error: token recognition error at: '@'
9 // | 1 @ 1
10 // | ..^
11 // ERROR: <input>:1:5: Syntax error: extraneous input '1' expecting <EOF>
12 // | 1 @ 1
13 // | ....^
14 eprintln!("{e}");
15 }
16}
17
18fn evaluate() -> anyhow::Result<()> {
19 Program::compile("1 @ 1")?;
20 unreachable!()
21}