diff --git a/exercises/13_error_handling/errors3.rs b/exercises/13_error_handling/errors3.rs index 8e8c38a2..c75c9eb5 100644 --- a/exercises/13_error_handling/errors3.rs +++ b/exercises/13_error_handling/errors3.rs @@ -20,12 +20,19 @@ fn main() { let pretend_user_input = "8"; // Don't change this line. - let cost = total_cost(pretend_user_input)?; + let cost = total_cost(pretend_user_input); - if cost > tokens { - println!("You can't afford that many!"); - } else { - tokens -= cost; - println!("You now have {tokens} tokens."); + match cost { + Ok(cost) => { + if cost > tokens { + println!("You can't afford that many!"); + } else { + tokens -= cost; + println!("You now have {tokens} tokens."); + } + }, + Err(error) => { + println!("Error calculating the total cost: {}", error) + } } }