Skip to content

Tracking Issue for ExitStatusError #84908

Open
@ijackson

Description

@ijackson

Feature gate: #![feature(exit_status_error)]

This is a tracking issue for ExitStatusError (and ExitStatus::exit_ok).

This feature makes it convenient to properly check the exit status of subprocesses (such as from Command)

Example

use std::process::Command;

let bad = Command::new("false").status().unwrap().exit_ok().unwrap_err();
assert_eq!(bad.code(), Some(1));

Public API

(In pseudo-syntax:)

impl ExitStatus {
    fn exit_ok(self) -> Result<(), ExitStatusError> {..}
}

pub struct ExitStatusError(...); // newtype around a NonZero integer
impl Eq,Copy,Debug,Error,Display for ExitStatusError;
impl Into<ExitStatus> for ExitStatusError;
impl ExitStatusError  {
    fn code(&self) -> Option<i32> {..} } // WIFEXITED WEXITSTATUS
    fn code_nonzero(&self) -> Option<NonZeroi32> {..}
    ...
}
impl ExitStatusExt for ExitStatusError; // .is_signal() etc.

impl Output {
  fn exit_ok(self) -> Result<Self, ExitStatusError>;
}

Steps / History

Unresolved Questions

  • None yet.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-error-handlingArea: Error handlingC-tracking-issueCategory: An issue tracking the progress of sth. like the implementation of an RFCPG-error-handlingProject group: Error handling (https://github.com/rust-lang/project-error-handling)T-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions