Skip to main content

error_handling/
error_handling.rs

1use async_jsonata_rust::functions::math;
2use async_jsonata_rust::Parser;
3
4fn main() {
5    match Parser::new().parse("1+") {
6        Ok(_) => println!("Unexpected parse success"),
7        Err(err) => println!("Parse error: {} at {:?}", err.code(), err.position()),
8    }
9
10    match math::sqrt(Some(-1.0)) {
11        Ok(value) => println!("Unexpected sqrt result: {:?}", value),
12        Err(err) => println!("Runtime error: {}: {}", err.code, err.message),
13    }
14}