Skip to content

Commit

Permalink
make error handling clearer with "if let"
Browse files Browse the repository at this point in the history
  • Loading branch information
kodesoul committed May 16, 2021
1 parent 7e61bcc commit 111bbf6
Showing 1 changed file with 6 additions and 12 deletions.
18 changes: 6 additions & 12 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,9 @@ fn run_joshuto(args: Args) -> Result<(), JoshutoError> {
return Ok(());
}
if let Some(p) = args.path.as_ref() {
match std::env::set_current_dir(p.as_path()) {
Ok(_) => {}
Err(e) => {
eprintln!("{}", e);
process::exit(1);
}
if let Err(e) = std::env::set_current_dir(p.as_path()) {
eprintln!("{}", e);
process::exit(1);
}
}

Expand Down Expand Up @@ -108,11 +105,8 @@ fn run_joshuto(args: Args) -> Result<(), JoshutoError> {
fn main() {
let args = Args::from_args();

match run_joshuto(args) {
Ok(_) => {}
Err(e) => {
eprintln!("{}", e.to_string());
process::exit(1);
}
if let Err(e) = run_joshuto(args) {
eprintln!("{}", e.to_string());
process::exit(1);
}
}

0 comments on commit 111bbf6

Please sign in to comment.