From 3288601040969f02d125ec99c0372af4c0f9d767 Mon Sep 17 00:00:00 2001 From: Ivan Bushchik Date: Wed, 25 Jan 2023 22:51:20 +0300 Subject: [PATCH] Add error handling --- Cargo.lock | 2 +- Cargo.toml | 2 +- src/main.rs | 6 +++++- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 1a28beb..4f80a2b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -10,7 +10,7 @@ checksum = "aacfb566035f8cd02f6ec9247c242f3f9904a0b288ea383abcf4e95df6436a34" [[package]] name = "feval" -version = "0.2.0" +version = "0.3.0" dependencies = [ "evalexpr", ] diff --git a/Cargo.toml b/Cargo.toml index 8372274..87e2f5b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "feval" -version = "0.2.0" +version = "0.3.0" edition = "2021" description = "clt for fast evaluations" readme = "README.md" diff --git a/src/main.rs b/src/main.rs index 48c03bc..ac4c1ee 100644 --- a/src/main.rs +++ b/src/main.rs @@ -30,7 +30,11 @@ fn main() { match args.len() { 2 => { let expr = all(args[1].clone()); - println!("{}", evalexpr::eval(&expr).unwrap()) + let result = evalexpr::eval(&expr.trim()); + match result { + Ok(succ_res) => println!("{}", succ_res), + Err(err) => println!("Error: {}", err) + } }, 1 => {main_loop()}, _ => {