Merge pull request #1 from NinVoido/add_err_handle

Add error handling
This commit is contained in:
Ivan Bushchik 2023-01-25 22:50:04 +03:00 committed by GitHub
commit 3395521ec5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -14,7 +14,11 @@ fn main_loop() {
stdout().flush().unwrap();
let mut input = String::new();
while stdin().read_line(&mut input).unwrap() != 0 {
println!("{}", evalexpr::eval(&input.trim()).unwrap());
let result = evalexpr::eval(&input.trim());
match result {
Ok(succ_res) => println!("{}", succ_res),
Err(err) => println!("Error: {}", err)
}
input.clear();
print!(">>> ");
stdout().flush().unwrap();