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 std::error::Error
for the new MSRV
#987
Conversation
std::error::Error
for the new MSRV
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.
ACK 74dc8ef
Didn't check that all the source
impls are correct, but it looks like you did a better job than the existing cause
ones..
I forgive you for patch 3.
If you feel like it could you remove the parenthesis and see if your emacs handles it or if its something strange in my environment? |
@tcharding I am using *actually it goes crazy handling git merge-conflict markers in postscript. But it never has problems with Rust. |
IIRC some guidelines recommend using |
Oh, from a previous comment you once made on which key shortcuts you use I thought you used emacs. I won't hold it against you ;) |
Thanks man, from my understanding, all the |
Put the match arms in the same order as the enum that defines them.
In an effort to be uniform throughout the codebase; put the `std::error::Error` impl block below the `Display` impl block.
Parenthesis are not needed around this expression but my editor is going mad and cannot format the code without them. Since it does not hurt readability add parenthesis around the expression.
Audit ever error type we have and implement `source` for each.
Face palm, I did this same work in
My OCD cannot handle that so I'll fix them both tomorrow, sending this to draft. Please comment if you have an opinion on these otherwise I'll arbitrarily pick and do them all the same. |
What's the benefit of implementing |
@elichai being explicit so that we know we didn't just forget about one of the impls. Also explicitly enumerating all the variants forces us to update the impl in case we later add a non- |
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.
Did a review and all sources that covered it. Did not check whether we covered all possible Error enums in the repository.
|
||
match self { | ||
Io(e) => Some(e), | ||
SocketMutexPoisoned | SocketNotConnectedToPeer => None, |
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.
I could not find any instances of SocketMutexPiosoned
and SocketNotConnectedError
. These should perhaps be removed.
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.
Cheers. This should be caught by the linter, now edition 2018 is here we can start thinking about getting the codebase linting cleanly.
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.
ACK 97a5bb1
Since this got merged, we will really need to fix (I'm back, should be able to go through most issues/PRs during this week.) |
Damn! @apoelstra, after all our chats about not implicitly de-referencing I did the opposite and matched on Old habits die hard. Please do pull me up if you happen to notice this ever in any PRs. |
Doesn't clippy complain about the opposite? |
Lol @tcharding I didn't even notice. Unfortunately these checks are basically impossible to reliably do mentally. Also lol if Clippy actually complains about not using weak-typing antifeatures. |
I don't think it's anti-feature since even though types are weird it's quite obvious what it does. I remember when it wasn't in the language and writing Rust those days was quite annoying. I did welcome the change. |
57dd673 Do not print error when displaying for std builds (Tobin C. Harding) b80cfee Bind to error_kind instead of e (Tobin C. Harding) 241ec72 Bind to b instead of e (Tobin C. Harding) 01f481b Bind to s instead of e (Tobin C. Harding) 5c6d369 network: Remove unused error variants (Tobin C. Harding) e67e97b Put From impl below std::error::Error impl (Tobin C. Harding) 6ca98e5 Remove error TODO (Tobin C. Harding) Pull request description: As part of the ongoing error improvement work and as a direct result of [this comment](#987 (comment)) improve the `Display` implementations of all our error types so as to not repeat the source error when printing. The first 5 patches are trivial clean ups around the errors. Patch 6 is the real work. EDIT: ~CC @Kixunil, have I got the right idea here bro?~ Patch 6 now includes a macro as suggested. ACKs for top commit: Kixunil: ACK 57dd673 apoelstra: ACK 57dd673 sanket1729: ACK 57dd673. Did not check if we covered all cases. We need to remember to use `write_err!` instead of `write!` in future. Tree-SHA512: 1ed26b0cc5f9a0f71684c431cbb9f94404c116c9136be696434c56a2f56fd93cb5406b0955edbd0dc6f8612e77345c93fa70a70650118968cc58e680333a41de
…r the new MSRV 97a5bb1 Implement std::error::source codebase wide (Tobin C. Harding) 0a9191b Add parenthesis around left hand side of companion (Tobin C. Harding) 7cf8af2 Put Error impl block below Display (Tobin C. Harding) 2384712 Re-order Display match arms (Tobin C. Harding) Pull request description: Now that we have MSRV of 1.41.1 we should use `source` instead of `cause`. Audit the whole codebase and implement `source` for _every_ error type we have. The first three patches are preparatory cleanup, patch 3 is particularly shameful (adds parenthesis to make my editor work). CC @Kixunil because he is championing the error stuff. ACKs for top commit: apoelstra: ACK 97a5bb1 Tree-SHA512: 46313a28929445f32e01e30ca3b0246b30bc9d5e43db5754d4b441e9c30d3e427efaf247100eb6b452f98beec5a4fcde1daba7943a772114aa34f78ab52cbc60
…ntations 57dd673 Do not print error when displaying for std builds (Tobin C. Harding) b80cfee Bind to error_kind instead of e (Tobin C. Harding) 241ec72 Bind to b instead of e (Tobin C. Harding) 01f481b Bind to s instead of e (Tobin C. Harding) 5c6d369 network: Remove unused error variants (Tobin C. Harding) e67e97b Put From impl below std::error::Error impl (Tobin C. Harding) 6ca98e5 Remove error TODO (Tobin C. Harding) Pull request description: As part of the ongoing error improvement work and as a direct result of [this comment](rust-bitcoin/rust-bitcoin#987 (comment)) improve the `Display` implementations of all our error types so as to not repeat the source error when printing. The first 5 patches are trivial clean ups around the errors. Patch 6 is the real work. EDIT: ~CC @Kixunil, have I got the right idea here bro?~ Patch 6 now includes a macro as suggested. ACKs for top commit: Kixunil: ACK 57dd673 apoelstra: ACK 57dd673 sanket1729: ACK 57dd673. Did not check if we covered all cases. We need to remember to use `write_err!` instead of `write!` in future. Tree-SHA512: 1ed26b0cc5f9a0f71684c431cbb9f94404c116c9136be696434c56a2f56fd93cb5406b0955edbd0dc6f8612e77345c93fa70a70650118968cc58e680333a41de
Now that we have MSRV of 1.41.1 we should use
source
instead ofcause
. Audit the whole codebase and implementsource
for every error type we have.The first three patches are preparatory cleanup, patch 3 is particularly shameful (adds parenthesis to make my editor work).
CC @Kixunil because he is championing the error stuff.