-
Notifications
You must be signed in to change notification settings - Fork 308
refactor!: convert from snafu to n0-error #3561
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
Conversation
|
Documentation for this PR has been generated and is available at: https://n0-computer.github.io/iroh/pr/3561/docs/iroh/ Last updated: 2025-11-03T18:49:21Z |
32458a9 to
7f59c66
Compare
| disco::Message::from_bytes(&sealed_box).context(ParseSnafu) | ||
| .map_err(|source| e!(DiscoBoxError::Open { source }))?; | ||
| disco::Message::from_bytes(&sealed_box) | ||
| .map_err(|source| e!(DiscoBoxError::Parse { source })) |
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.
what's the difference between
e!(DiscoBoxError::Parse { source })and
e!(DiscoBoxError::Parse, source)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.
None, they're identical. Both expand to DiscoBoxError::Parse { source, meta: Meta::default() }
## Description `cargo fmt` can't handle code inside `tokio::select!` and the big match statement had numerous formatting issues, so I moved it into a function. ## Breaking Changes <!-- Optional, if there are any breaking changes document them, including how to migrate older code. --> ## Notes & open questions <!-- Any notes, remarks or open questions you have to make about the PR. --> ## Change checklist <!-- Remove any that are not relevant. --> - [ ] Self-review. - [ ] Documentation updates following the [style guide](https://rust-lang.github.io/rfcs/1574-more-api-documentation-conventions.html#appendix-a-full-conventions-text), if relevant. - [ ] Tests if relevant. - [ ] All breaking changes documented. - [ ] List all breaking changes in the above "Breaking Changes" section. - [ ] Open an issue or PR on any number0 repos that are affected by this breaking change. Give guidance on how the updates should be handled or do the actual updates themselves. The major ones are: - [ ] [`quic-rpc`](https://github.com/n0-computer/quic-rpc) - [ ] [`iroh-gossip`](https://github.com/n0-computer/iroh-gossip) - [ ] [`iroh-blobs`](https://github.com/n0-computer/iroh-blobs) - [ ] [`dumbpipe`](https://github.com/n0-computer/dumbpipe) - [ ] [`sendme`](https://github.com/n0-computer/sendme)
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 only have small nits.
LGTM!
| if response.status() != hyper::StatusCode::SWITCHING_PROTOCOLS { | ||
| UnexpectedUpgradeStatusSnafu { | ||
| code: response.status(), | ||
| n0_error::ensure!( |
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 think there's a place we missed importing the macro
| n0_error::ensure!( | |
| ensure!( |
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 function is #[cfg(not(wasm_browser))] and this is the only occurence of ensure in this module, so I left it like this instead of doing a conditional import of ensure at the module level.
| #[cfg(not(feature = "test-utils"))] | ||
| { | ||
| snafu::whatever!( | ||
| n0_error::bail_any!( |
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.
Nit: some more qualified uses
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 is in a conditioanl section, not sure what's better, keep it like this or conditional import at module level?
Description
Changes the error handling across all crates in this repo from
snafu/n0-snafuton0-error. The latter is our new error library which features call-site location tracking and better ergonomics than snafu.Repo: https://github.com/n0-computer/n0-error
Docs: https://docs.rs/n0-error/
Note: The initial version of this PR was written by an AI (OpenAI codex) which I instructed in numerous prompts to convert iroh from n0-snafu/snafu to n0-error. It has since been cleaned up and reviewed line-by-line.
Breaking Changes
Changed
meta: n0_error::Meta. Fieldsbacktraceandspan_traceare removed.snafu::ErrorCompat. They now implementn0_error::StackError. All our errors keep implementingstd::error::Error. For downstream uses of these errors, not much changed.n0-snafuto work with iroh errors, we recommend you switch ton0-error. See the docs for how to work with n0-error.Notes & open questions
Change checklist
quic-rpciroh-gossipiroh-blobsdumbpipesendme