Skip to content

Commit

Permalink
finish errors5
Browse files Browse the repository at this point in the history
  • Loading branch information
cyz-ing committed Jan 27, 2025
1 parent 9a6585d commit 9ee5008
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions exercises/error_handling/errors5.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,11 @@ use std::fmt;
use std::num::ParseIntError;

// TODO: update the return type of `main()` to make this compile.
fn main() -> Result<(), Box<dyn ???>> {
fn main() -> Result<(), Box<dyn std::error::Error>> {
let pretend_user_input = "42";
let x: i64 = pretend_user_input.parse()?;
println!("output={:?}", PositiveNonzeroInteger::new(x)?);
let x: i64 = pretend_user_input.parse().map_err(|e| Box::new(e) as Box<dyn std::error::Error>)?;
let result = PositiveNonzeroInteger::new(x).map_err(|e| Box::new(e) as Box<dyn std::error::Error>)?;
println!("output={:?}", result);
Ok(())
}

Expand Down

0 comments on commit 9ee5008

Please sign in to comment.