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

Non-zero status codes should better differentiate why (at which stage) the command failed #4379

Open
jchlapinski opened this issue Aug 7, 2017 · 3 comments
Labels
A-diagnostics Area: Error and warning messages generated by Cargo itself. C-enhancement Category: enhancement P-low Priority: Low S-needs-design Status: Needs someone to work further on the design for the feature or fix. NOT YET accepted.

Comments

@jchlapinski
Copy link

jchlapinski commented Aug 7, 2017

At the moment, cargo only seem to support three values for status code (gathered from https://github.com/rust-lang/cargo/tree/master/tests):

  • 0 - success
  • 1 - returned when cargo verify-project is run with incorrect --manifest-path
  • 101 - failure

TL;DR:
I would like for cargo to return different non-zero status codes for at least:

  • compilation errors
  • test failures

Optionally:

  • invalid arguments, syntax errors

Reasoning:
My problem is that I need a fix for this issue: kennytm/cargo-kcov#16, where cargo kcov should generate coverage report regardless of whether the tests failed or not. This issue would be much simpler to fix if cargo returned different status code for failures during compilation stage (in which case cargo kcov needs to fail as well) and different status code if the tests failed (in which case it might continue with preparing coverage report).

I can prepare PR for cargo myself, but I would like to know if this would be acceptable change for cargo beforehand.

Regards

@jchlapinski jchlapinski changed the title Non-zero status codes should better differentiate why the command failed Non-zero status codes should better differentiate why (at which stage) the command failed Aug 7, 2017
@alexcrichton
Copy link
Member

Seems plausible to me!

@carols10cents carols10cents added A-diagnostics Area: Error and warning messages generated by Cargo itself. C-enhancement Category: enhancement labels Aug 27, 2017
@epage epage added the S-needs-design Status: Needs someone to work further on the design for the feature or fix. NOT YET accepted. label Oct 14, 2023
@epage
Copy link
Contributor

epage commented Oct 14, 2023

Personally, I think I'd prefer for us to focus on json messages for our errors as that would be a lot more specific and more fine grained than we could get with error codes. Unsure if that makes this worth closing or not.

If someone were to move this forward, they'd need to figure out

  • What operations deserve a dedicated error code (the biggest risk being that an operation with a more specific error code can't be split up further)
  • How we can avoid holes in this "API"
  • How we avoid breaking compatibility on this "API"

@weihanglo
Copy link
Member

I understand that it's pretty convenient to just parse the exit code then go. Another use case is a exit code for retryable errors.

However, as previously stated out, JSON or other machine-readable format could be better for programming use cases. We do need to figure out questions above to move on. Currently it doesn't seem a high priority.

@weihanglo weihanglo added the P-low Priority: Low label Oct 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Error and warning messages generated by Cargo itself. C-enhancement Category: enhancement P-low Priority: Low S-needs-design Status: Needs someone to work further on the design for the feature or fix. NOT YET accepted.
Projects
None yet
Development

No branches or pull requests

5 participants