-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Open
Labels
A-error-handlingArea: Error handlingArea: Error handlingC-tracking-issueCategory: An issue tracking the progress of sth. like the implementation of an RFCCategory: 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)Project 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.Relevant to the library API team, which will review and decide on the PR/issue.
Description
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
- Implementation: Provide ExitStatusError #82973
- ACP for
Output::exit_ok
Addstd::process::Output::exit_ok
libs-team#554 - Final commenting period (FCP)
- Stabilization PR (including restoring mentions in
ExitStatus
docs) - Add
#[must_use]
toprocess::ExitStatus
(previous attempt Add #[must_use] to process::Command, process::Child and process::ExitStatus #81452); see also Tracking Issue for std::process error handling #73131. - Consider implementing
Try
forExitStatus
Unresolved Questions
- None yet.
seanfisk, MaxVerevkin, smasher164, kkocdko, desbma and 34 more
Metadata
Metadata
Assignees
Labels
A-error-handlingArea: Error handlingArea: Error handlingC-tracking-issueCategory: An issue tracking the progress of sth. like the implementation of an RFCCategory: 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)Project 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.Relevant to the library API team, which will review and decide on the PR/issue.