Skip to content
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
@epage

Description

@epage

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::Commands 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::Commands and std::io::ErrorKinds to codes
    • enum for policy enforcement / targeted extending with traits
    • But can't represent states not known a priori
  • exit-code and exitcode
    • Includes common codes as i32 constants
  • proc-exit
    • Includes common codes and signals
    • Convert std::process::Commands and std::io::ErrorKinds 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 into Display for Termination trait
  • proc-exit
    • Turns Debug into Display if choosing to rely on Termination 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions