Skip to content

Commit

Permalink
Use early return in the entry point
Browse files Browse the repository at this point in the history
  • Loading branch information
sorairolake committed Dec 4, 2023
1 parent f2acea0 commit b134452
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions crates/cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,13 @@ fn main() -> ExitCode {
Ok(()) => ExitCode::SUCCESS,
Err(err) => {
eprintln!("Error: {err:?}");
#[allow(clippy::option_if_let_else)]
if let Some(e) = err.downcast_ref::<io::Error>() {
sysexits::ExitCode::from(e.kind()).into()
} else if err.is::<abcrypt::Error>() {
sysexits::ExitCode::DataErr.into()
} else {
ExitCode::FAILURE
return sysexits::ExitCode::from(e.kind()).into();
}
if err.is::<abcrypt::Error>() {
return sysexits::ExitCode::DataErr.into();
}
ExitCode::FAILURE
}
}
}

0 comments on commit b134452

Please sign in to comment.