-
Notifications
You must be signed in to change notification settings - Fork 237
feat!: concrete errors #3161
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
Open
dignifiedquire
wants to merge
61
commits into
main
Choose a base branch
from
feat-relay-errors
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
feat!: concrete errors #3161
Changes from all commits
Commits
Show all changes
61 commits
Select commit
Hold shift + click to select a range
a673d59
wip: concrete errors for iroh-relay
dignifiedquire c36d53e
fixup
dignifiedquire 3f7f209
use git dependency for n0-snafu
dignifiedquire deca8f8
convert iroh-base to snafu
dignifiedquire a26857c
use macro to DRY the snafu error enum (#3275)
rklaehn 45bb23c
refactor: convert iroh::disco to snafu
dignifiedquire f35d33c
refactor(iroh): switch thiserror to snafu
dignifiedquire 42a8d73
refactor(iroh): convert reportgen/hairpin
dignifiedquire 481b05d
prepare endoint.rs for conversion
dignifiedquire 958c917
explicit use of anyhow::Result in magicsock
dignifiedquire d6cd802
use explicit anyhow::Result in the rest of iroh
dignifiedquire 9a1cc49
refactor(iroh): transform magicsock/relay-actor
dignifiedquire d3589e0
start refactoring magicsock
dignifiedquire 9e3c48b
refactor(iroh): introduce AddNodeaddrError
dignifiedquire dd6f59e
refactor(iroh): introduce netreporterror
dignifiedquire c8ca621
refactor(iroh): make Actor::run infallible
dignifiedquire 0a04f6f
refactor: endpoint.rs is free
dignifiedquire e29d5ae
feat(iroh-relay): Convert all client-side errors to snafu (#3283)
matheus23 ba32bc6
Merge remote-tracking branch 'origin/main' into feat-relay-errors
matheus23 877200e
Fix types after merge
matheus23 ed3ed0d
Make `iroh-base` use snafu more similar to other code (#3285)
matheus23 4f92aa7
refactor: net_report.rs is free
dignifiedquire 7c0b111
refactor(iroh): start conversion of reportgen
dignifiedquire 8b7fe74
probes: custom erroor
dignifiedquire fa1e1c3
net_report is free
dignifiedquire 3d347ab
feat(iroh-relay): replace `anyhow` with `snafu` in the server side of…
ramfox f99ca2a
feat(iroh): convert `discovery` module to use `snafu` errors (#3287)
ramfox fe1d922
feat: make Router::spawn sync and infallible
dignifiedquire dc47f65
feat: make make_client_config infallible
dignifiedquire a0f67a1
refactor protocol error handling
dignifiedquire 4742774
iroh: anyhow is now a dev dependency
dignifiedquire 11b39f4
spelling
ea81665
improve discovery errors
dignifiedquire 1797a14
fix clippy in endpoint.rs
dignifiedquire a5b6280
update dep
dignifiedquire 2da8c10
fixup errors
dignifiedquire 445b4f0
fix relay proto decoding
dignifiedquire 9b23464
Cleanup unused `snafu(visibility(pub(crate)))` (#3289)
matheus23 f69a63c
use published n0-snafu
dignifiedquire f9af46e
refactor(relay): drop anyhow and testresult
dignifiedquire 445e533
refactor: convert iroh-dns-server
dignifiedquire 6e4a311
fixups in iroh-relay
dignifiedquire c288607
fixup: bench
dignifiedquire 16de8ca
convert discovery tests from `anyhow` to `snafu`
05f3686
missed some in `discovery.rs`
8440102
replace `anyhow` with `n0_snafu` in `magicsock` tests
8f6a09c
Merge branch 'main' into feat-relay-errors
9b0ccfc
refactor: convert iroh/bench
dignifiedquire ff23a7a
chore(iroh): Convert tests to using `n0_snafu::TestResult` (#3291)
matheus23 c35dda8
move anyhow to examples
dignifiedquire 17b5237
drop thiserror
dignifiedquire 73aeceb
test: remove remaining usages of testresult
dignifiedquire fc14fc3
fix: downgrade redb for MSRV stability
dignifiedquire 757d161
Merge remote-tracking branch 'origin/main' into feat-relay-errors
dignifiedquire ac8b174
Merge remote-tracking branch 'origin/main' into feat-relay-errors
dignifiedquire 63ad858
Merge remote-tracking branch 'origin/main' into feat-relay-errors
6cc2483
merge cleanup
6ee45e0
replace `context` with `e` in `iroh-dns-server` where the context doe…
e96c74b
rename `TestError`, `TestResult`, `TestResultExt` to `Error`, `Result…
fee934f
Merge branch 'main' into feat-relay-errors
c67641f
change all error types named `Error` to a more specific name
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 |
---|---|---|
|
@@ -9,10 +9,12 @@ use std::{ | |
}; | ||
|
||
use curve25519_dalek::edwards::CompressedEdwardsY; | ||
pub use ed25519_dalek::Signature; | ||
use ed25519_dalek::{SignatureError, SigningKey, VerifyingKey}; | ||
pub use ed25519_dalek::{Signature, SignatureError}; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Will there be any regrets about re-exporting these without wrapping? |
||
use ed25519_dalek::{SigningKey, VerifyingKey}; | ||
use nested_enum_utils::common_fields; | ||
use rand_core::CryptoRngCore; | ||
use serde::{Deserialize, Serialize}; | ||
use snafu::{Backtrace, Snafu}; | ||
|
||
/// A public key. | ||
/// | ||
|
@@ -180,17 +182,26 @@ impl Display for PublicKey { | |
} | ||
|
||
/// Error when deserialising a [`PublicKey`] or a [`SecretKey`]. | ||
#[derive(thiserror::Error, Debug)] | ||
#[common_fields({ | ||
backtrace: Option<Backtrace>, | ||
#[snafu(implicit)] | ||
span_trace: n0_snafu::SpanTrace, | ||
})] | ||
#[derive(Snafu, Debug)] | ||
#[allow(missing_docs)] | ||
#[snafu(visibility(pub(crate)))] | ||
pub enum KeyParsingError { | ||
/// Error when decoding. | ||
#[error("decoding: {0}")] | ||
Decode(#[from] data_encoding::DecodeError), | ||
#[snafu(transparent)] | ||
Decode { source: data_encoding::DecodeError }, | ||
/// Error when decoding the public key. | ||
#[error("key: {0}")] | ||
Key(#[from] ed25519_dalek::SignatureError), | ||
#[snafu(transparent)] | ||
Key { | ||
source: ed25519_dalek::SignatureError, | ||
}, | ||
/// The encoded information had the wrong length. | ||
#[error("invalid length")] | ||
DecodeInvalidLength, | ||
#[snafu(display("invalid length"))] | ||
DecodeInvalidLength {}, | ||
} | ||
|
||
/// Deserialises the [`PublicKey`] from it's base32 encoding. | ||
|
@@ -333,14 +344,14 @@ fn decode_base32_hex(s: &str) -> Result<[u8; 32], KeyParsingError> { | |
let input = s.to_ascii_uppercase(); | ||
let input = input.as_bytes(); | ||
if data_encoding::BASE32_NOPAD.decode_len(input.len())? != bytes.len() { | ||
return Err(KeyParsingError::DecodeInvalidLength); | ||
return Err(DecodeInvalidLengthSnafu.build()); | ||
} | ||
data_encoding::BASE32_NOPAD.decode_mut(input, &mut bytes) | ||
}; | ||
match res { | ||
Ok(len) => { | ||
if len != PublicKey::LENGTH { | ||
return Err(KeyParsingError::DecodeInvalidLength); | ||
return Err(DecodeInvalidLengthSnafu.build()); | ||
} | ||
} | ||
Err(partial) => return Err(partial.error.into()), | ||
|
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
Oops, something went wrong.
Oops, something went wrong.
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.
Need to remember to replace this with a published version