[−][src]Macro die_exit::die
Prints a message to stderr
and terminates the current process with the specified exit code
or 1 if no exit code is specified, by calling eprintln
!() on all arguments followed by
process::exit(exit_code)
Examples
Basic usage:
ⓘ
die!("argument to -e must be numeric"); // prints message to stderr then exits with code 1
With custom error code:
ⓘ
die!(2; "argument to -e must be numeric"); // prints message to stderr then exits with code 2
error code can go at the beginning or end, just separate with colon:
ⓘ
die!("argument to -e must be numeric"; 3); // prints message to stderr then exits with code 3
supports all the formatting eprintln! does:
ⓘ
die!("argument {} must be {}", "-e", 1; 4); // prints `argument -e must be 1` to stderr then exits with code 4
supports all the formatting eprintln! does without exit code too:
ⓘ
die!("argument {} must be {}", "-e", 1); // prints `argument -e must be 1` to stderr then exits with code 1
just exit with a code alone:
ⓘ
die!(2); // prints nothing, only exits with code 3
just exit:
ⓘ
die!(); // prints nothing, only exits with code 1