Skip to content

Commit

Permalink
Don't crash program on illegal expression
Browse files Browse the repository at this point in the history
  • Loading branch information
funnyboy-roks committed Oct 25, 2023
1 parent 1b32f58 commit 9d74e30
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,15 @@ where

s.clear();

let result = eval.eval(&statement)?;
let result = match eval.eval(&statement) {
Ok(r) => r,
Err(e) => {
println!("Error evaluating equation: {:?}", e);
print!("> ");
stdout().flush()?;
continue;
}
};

eval.variable_map.insert("_".into(), result);

Expand Down

0 comments on commit 9d74e30

Please sign in to comment.