This repository was archived by the owner on Sep 12, 2024. It is now read-only.
This repository was archived by the owner on Sep 12, 2024. It is now read-only.
Dealing with process exit codes #22
Open
Description
There are two sides to this
Turning std::process::Command
into errors
Providing a way to bubble up process exit codes to main
- Some times a user will want a
std::process::Command
s exit code to bubble up, sometimes they won't - Some times a user will want an
std::io::ErrorKind
to bubble up and sometimes they won't - Certain operations get distinct error code: usage/config/generic error vs special error that a third-party needs to programmatically process
Alternative:
- Directly calling
std::process::exit
throughout the business logic. Personally, I've found unexpected forms of exiting a program to lead to "spaghetti code".
Exit code prior art:
std::process::ExitCode
- Only two codes defined
- Newtype for policy enforcement / targeted extending with traits
sysexit
- Includes common codes and signals
- Convert
std::process::Command
s andstd::io::ErrorKind
s to codes - enum for policy enforcement / targeted extending with traits
- But can't represent states not known a priori
exit-code
andexitcode
- Includes common codes as
i32
constants
- Includes common codes as
proc-exit
- Includes common codes and signals
- Convert
std::process::Command
s andstd::io::ErrorKind
s to codes - Newtype for policy enforcement / targeted extending with traits
main
prior art:
std::process::Termination
- A blanket impl makes it difficult for people to provide their own status codes
- exitfailure
- Turns
Debug
intoDisplay
forTermination
trait
- Turns
proc-exit
- Turns
Debug
intoDisplay
if choosing to rely onTermination
trait - Allows "silent" exit (error message got logged previously, so don't print anything on process exit)
- When not integrating with
Termination
, provides a way to get custom exit codes to the user
- Turns
Metadata
Metadata
Assignees
Labels
No labels