Module exit_code

Module exit_code 

Source
Expand description

§Exit Code Management

Provides standardized Unix exit codes following BSD sysexits.h conventions.

§Exit Code Conventions

  • 0: Success
  • 1: General error
  • 2: Misuse of shell command (reserved by Bash)
  • 64-78: Specific error conditions (BSD sysexits.h)
  • 126: Command cannot execute
  • 127: Command not found
  • 128+N: Fatal signal N (e.g., 130 = SIGINT)

§Usage

use adaptive_pipeline_bootstrap::exit_code::ExitCode;

fn run_application() -> Result<(), Box<dyn std::error::Error>> {
    // Application logic here
    Ok(())
}

fn main() {
    let result = run_application();
    let exit_code = match result {
        Ok(_) => ExitCode::Success,
        Err(e) => ExitCode::from_error(e.as_ref()),
    };
    std::process::exit(exit_code.as_i32());
}

Enums§

ExitCode
Exit codes following Unix conventions (BSD sysexits.h)

Functions§

map_error_to_exit_code
Maps application error messages to Unix exit codes (sysexits.h standard)
result_to_exit_code
Maps a Result to a process exit code