Skip to content

Commit

Permalink
function main returns exit status
Browse files Browse the repository at this point in the history
  • Loading branch information
Keksoj committed Aug 9, 2024
1 parent 995eb6b commit 0849163
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions bin/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,18 @@ enum MainError {
BeginNewMain(UpgradeError),
#[error("{0}")]
Cli(CtlError),
#[error("paw io error: {0}")]
Io(std::io::Error),
}

impl From<std::io::Error> for MainError {
fn from(value: std::io::Error) -> Self {
Self::Io(value)
}
}

#[paw::main]
fn main(args: Args) {
fn main(args: Args) -> Result<(), MainError> {
register_panic_hook();

let result = match args.cmd {
Expand Down Expand Up @@ -119,10 +127,11 @@ fn main(args: Args) {
}
_ => ctl::ctl(args).map_err(MainError::Cli),
};
match result {
Ok(_) => {}
Err(main_error) => println!("{}", main_error),

if let Err(main_error) = &result {
eprintln!("\n{main_error}\n");
}
result
}

/// Set workers process affinity, see man sched_setaffinity
Expand Down

0 comments on commit 0849163

Please sign in to comment.