-
Notifications
You must be signed in to change notification settings - Fork 85
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 Termination
for error_stack::Report
#671
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @gluax and thank you very much for the contribution!
I really like the idea of implementing Termination
on Report
. However, I think the API can be simplified (see comments). This sadly requires a nightly compiler to really use ExitCode
, but as soon as the Provider API is stabilized, this would also be available on stable.
@gluax This is awesome, thanks for contributing! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for applying the suggestions!
Would be great if you could add a small test checking for the right exit code. We don't have a tests
module in report.rs yet, you may add one at the bottom of the file. 👍🏻
Example and test added! As well as the other suggested changes. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only a few suggestions that you should be able to apply directly from GitHub, otherwise it seems to be ready for merging.
In order to merge, the Rust jobs and the CI-linting job has to pass, others can be ignored (they fail because of insufficient permissions, nothing you should need to worry about).
Co-authored-by: Tim Diekmann <21277928+TimDiekmann@users.noreply.github.com>
Co-authored-by: Tim Diekmann <21277928+TimDiekmann@users.noreply.github.com>
Co-authored-by: Tim Diekmann <21277928+TimDiekmann@users.noreply.github.com>
Termination
(https://doc.rust-lang.org/stable/std/process/trait.Termination.html) for Report
Termination
(https://doc.rust-lang.org/stable/std/process/trait.Termination.html) for Report
Termination
for error_stack::Report
Thank you very much for your contribution, I really appreciate it! 🎉 |
🌟 What is the purpose of this PR?
This adds custom error code support for
error-stack
🔗 Related links
Closed #670.
Though the implementation has changed since I wrote the issue and learned more about the code base.
🔍 What does this change?
Adds a methodattach_exit_code(mut self, exit_code: u8) -> Self
on theReport<C>
struct.Adds a new fieldexit_code: Option<u8>
on theReportImpl
struct.Termination
trait for theReport<C>
struct.📜 Does this require a change to the docs?
The docs have been added.
🐾 Next steps
Please let me know if there are any changes that should be made.
🛡 What tests cover this?
There is the test doc test that passes. Let me know if I should add a separate test.
❓ How to test this?
feature/custom-exit-code
branch.cargo test --doc
📹 Demo