Skip to content

Commit

Permalink
fix: exit gracefully instead of immediate termination
Browse files Browse the repository at this point in the history
  • Loading branch information
charislam committed Jan 22, 2025
1 parent 51f81db commit cb62cfc
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use std::{
env,
io::{BufWriter, Write},
path::PathBuf,
process,
process::{self, ExitCode},
time::Instant,
};

Expand Down Expand Up @@ -186,12 +186,12 @@ fn execute() -> Result<Result<()>> {
}
}

fn main() {
fn main() -> ExitCode {
match execute() {
Ok(Ok(())) => process::exit(exitcode::OK),
Ok(Err(_)) => process::exit(exitcode::DATAERR),
Ok(Ok(())) => ExitCode::SUCCESS,
Ok(Err(_)) => ExitCode::from(TryInto::<u8>::try_into(exitcode::DATAERR).unwrap()),
// Not really, but we need to bubble better errors up to get a more
// meaningful exit code.
Err(_) => process::exit(exitcode::SOFTWARE),
Err(_) => ExitCode::from(TryInto::<u8>::try_into(exitcode::SOFTWARE).unwrap()),
}
}

0 comments on commit cb62cfc

Please sign in to comment.