Skip to content

Conversation

skaunov
Copy link
Contributor

@skaunov skaunov commented Sep 26, 2025

Description

Fix visibility so downstream could differentiate between NoConnection and StreamFailed.

Notes & open questions

I guess this one doesn't need adding a test, but if you suggest a good one that would be interesting. Though I can imagine you'd like to add this somewhere in the integration tests on the whole libp2p level in a separate issue.

Change checklist

  • I have performed a self-review of my own code
  • I have made corresponding changes to the documentation
  • I have added tests that prove my fix is effective or that my feature works
  • A changelog entry has been made in the appropriate crates

Copy link
Member

@dariusc93 dariusc93 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR. Left a comment below

Comment on lines -377 to -391
pub struct Error {
pub(crate) inner: dial_request::DialBackError,
}

impl Display for Error {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
Display::fmt(&self.inner, f)
}
}

impl Debug for Error {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
Debug::fmt(&self.inner, f)
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldnt it be better to leave this in place but implement Error (or maybe use thiserror::Error and use #[error(transparent)]) so you can downcast to DialBackError?

Copy link
Contributor Author

@skaunov skaunov Sep 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I honestly gave that a small thought initially. I definitely like the second approach more. But I fail to identify a benefit from that layer of indirection, so came with this approach; do you have some on your mind? Like IIRC the idea of thiserror is that someone downstream who uses it can wrap this easily for their needs, and we don't imply it on those who don't want to use it. 😆

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants