-
Notifications
You must be signed in to change notification settings - Fork 1.1k
fix(swarm): display cause of denied listen error #4232
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
Merged
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
8ce9d2e
display cause of denied listen error
divagant-martian 973e4d1
attempt at changelog
divagant-martian 95095a6
swarm version up
divagant-martian 25f4931
Update swarm/CHANGELOG.md
divagant-martian 34c5f36
Merge branch 'master' into master
divagant-martian b607c67
Merge branch 'master' into master
divagant-martian 48c2aa1
lockfile
divagant-martian 5ffb4d0
Merge branch 'master' into master
divagant-martian ebc0a5f
workspace dep
divagant-martian bd820a9
Merge branch 'master' into master
mergify[bot] 0080238
Merge branch 'master' into master
mergify[bot] File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,7 @@ name = "libp2p-swarm" | |
edition = "2021" | ||
rust-version = { workspace = true } | ||
description = "The libp2p swarm" | ||
version = "0.43.1" | ||
version = "0.43.2" | ||
authors = ["Parity Technologies <[email protected]>"] | ||
license = "MIT" | ||
repository = "https://github.com/libp2p/rust-libp2p" | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
This cause is already available as part of calling
Error::source
. Including it in thefmt::Display
as well is kind of an anti-pattern because it leads to double-printing of errors.If we print it here, we should remove it from
Error::source
. Also, if you use something likeanyhow
, the source would be printed which I personally find the better approach than printing it here because stringifies as "late" as possible.Uh oh!
There was an error while loading. Please reload this page.
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.
first let me explain the reason for this: we get an error, we print it and get no information at all about this. The implementation of
Display
comes before the one forError
(sinceError: Display
) so it should be up to theError
implementation to deal with this differently if necessary.If trait
A
depends on traitB
whereB
on itself is useful and publicly available, I would argue it's an anti-pattern to decideB
's implementation just to satisfy something aboutA
. More so of if that comes down to removing important informationThere 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.
The issue with that is that it is quite hard to go from a string implementation back to structured data.
This is btw also the "official" recommendation, see rust-lang/project-error-handling#27 (comment).
What is missing the Rust ecosystem is a default way of printing errors. Yes, errors can be displayed but if I understand the error handling project group correctly, then at some point, there will be a std-built-in way of printing an error that will correctly chain them together. Until then, users are encouraged to use things like
anyhow
oreyre
.Personally, I mildly prefer to keep the display impls short and instead return sources from
Error::source
. This is still correct from an API point of view: This particular error itself says what happened, i.e. it explains one layer of the entire stack. But looking at errors out of context is seldomly meaningful which is why one should go down the chain of sources.I'd say it is exactly the opposite actually. By stringifying the error + its sources in the
Display
impl, theDisplay
impl (which is more general than theError
trait), makes an assumption what it is going to be used for (printing chains of errors) when technically, it shouldn't know about the concept of a "source error".I am not too fussed which way we go until there is a definite answer from the Rust project but what I want to avoid is double printing of errors when used with a library like
anyhow
. To avoid this, the inner error needs to be removed fromsource
. Are you open to sending a patch for this?