feat(users/Profpatsch): add die_* helpers for semantic exit errors
There is this semantic exit code schema championed by execline and
skaware tooling, and we refined and documented it a bit in lorri
d1d673d420/src/ops/mod.rs (L24-L35)
in the past.
This just transcribes the error messages into simple helper functions.
Applies the functions to the places where we would panic or die
`sys::exit()` instead.
Change-Id: I15ca05cd6f99a25a3378518be94110eab416354e
Reviewed-on: https://cl.tvl.fyi/c/depot/+/2475
Tested-by: BuildkiteCI
Reviewed-by: Profpatsch <mail@profpatsch.de>
This commit is contained in:
parent
83634341aa
commit
492b79ec7a
5 changed files with 80 additions and 28 deletions
|
|
@ -30,7 +30,10 @@ let
|
|||
|
||||
netencode-rs-common = tests: imports.writers.rustSimpleLib {
|
||||
name = "netencode";
|
||||
dependencies = [ nom ];
|
||||
dependencies = [
|
||||
nom
|
||||
depot.users.Profpatsch.execline.exec-helpers
|
||||
];
|
||||
buildTests = tests;
|
||||
release = false;
|
||||
verbose = true;
|
||||
|
|
@ -101,13 +104,13 @@ let
|
|||
use netencode::dec::{Record, ScalarAsBytes, Decoder, DecodeError};
|
||||
|
||||
fn main() {
|
||||
let t = netencode::t_from_stdin_or_panic("record-splice-env");
|
||||
let t = netencode::t_from_stdin_or_die_user_error("record-splice-env");
|
||||
let (_, prog) = exec_helpers::args_for_exec("record-splice-env", 0);
|
||||
match Record::<ScalarAsBytes>::dec(t) {
|
||||
Ok(map) => {
|
||||
exec_helpers::exec_into_args("record-splice-env", prog, map);
|
||||
},
|
||||
Err(DecodeError(err)) => panic!("{}", err),
|
||||
Err(DecodeError(err)) => exec_helpers::die_user_error("record-splice-env", err),
|
||||
}
|
||||
}
|
||||
'';
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue