pub trait ExitCode: Sealed {
// Provided method
fn exit_code(&self) -> i32 { ... }
}
Expand description
CLI application exit code
18
19
20
21
22
23
24
25
26
fn main() {
let path = PathBuf::from("/not/an/exsisting/file");
let res = run(path);
if let Err(ref err) = res {
report::err_full(err);
std::process::exit(err.exit_code());
}
}
More examples
Hide additional examples
examples/wrap_report_exit.rs (
line 15)
8
9
10
11
12
13
14
15
16
17
fn main() {
let res = config_error()
.wrap(CliError::Config)
.add_help("See https://docs.example.rs/config for more info");
if let Err(ref err) = res {
report::err_full(err);
std::process::exit(err.exit_code());
}
}
examples/anyhow_report.rs (
line 30)
22
23
24
25
26
27
28
29
30
31
32
fn main() {
let res = inner_fn().context(CliError::OsErr);
if let Err(ref err) = res {
report::anyhow_err_full(err);
std::process::exit(err.exit_code());
}
}