Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement Try for ExitStatus #54889

Closed
fenhl opened this issue Oct 7, 2018 · 3 comments
Closed

Implement Try for ExitStatus #54889

fenhl opened this issue Oct 7, 2018 · 3 comments
Labels
A-error-handling Area: Error handling C-feature-request Category: A feature request, i.e: not implemented / a PR. PG-error-handling Project group: Error handling (https://github.com/rust-lang/project-error-handling) T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.

Comments

@fenhl
Copy link
Contributor

fenhl commented Oct 7, 2018

It would be useful if std::process::ExitStatus implemented std::ops::Try. This could reduce boilerplate code where multiple Commands need to be spawned and checked.

Open question: What's a good error type? ExitStatus itself already contains all the relevant error information from the command, but being able to return a result of Err(ExitStatus::from_code(0)) would be weird. (Thanks @scottmcm for pointing this out.)

@Centril Centril added T-libs-api Relevant to the library API team, which will review and decide on the PR/issue. C-feature-request Category: A feature request, i.e: not implemented / a PR. labels Oct 7, 2018
@scottmcm
Copy link
Member

scottmcm commented Oct 8, 2018

Note that if the trait redesign from #42327 (comment) were to happen, a distinct error type would no longer be needed and thus this would become substantially more reasonable.

@yaahc yaahc added the A-error-handling Area: Error handling label May 4, 2021
@luser
Copy link
Contributor

luser commented Jun 7, 2021

For a real-world example of where this would be useful, sccache runs compiler commands and wants to exit with the same status as the compiler:
https://github.com/mozilla/sccache/blob/3f318a8675e4c3de4f5e8ab2d086189f2ae5f5cf/src/lib.rs#L71
https://github.com/mozilla/sccache/blob/3f318a8675e4c3de4f5e8ab2d086189f2ae5f5cf/src/commands.rs#L526

@yaahc yaahc added the PG-error-handling Project group: Error handling (https://github.com/rust-lang/project-error-handling) label Sep 27, 2021
@ratmice
Copy link
Contributor

ratmice commented Jan 10, 2023

I believe that this should be closed as per the libs-api discussion in #93565

@dtolnay dtolnay closed this as completed Jan 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-error-handling Area: Error handling C-feature-request Category: A feature request, i.e: not implemented / a PR. PG-error-handling Project group: Error handling (https://github.com/rust-lang/project-error-handling) T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

7 participants