-
Couldn't load subscription status.
- Fork 56
Improve Error Handling #99
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
base: main
Are you sure you want to change the base?
Conversation
| /// The actual size of the RLP node in bytes | ||
| size: usize, | ||
| /// The maximum allowed size in bytes | ||
| max: usize, |
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 field seems redundant since max will always be 33, no?
| ProofVerification( | ||
| /// The reason for verification failure | ||
| String | ||
| ), |
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.
| ProofVerification( | |
| /// The reason for verification failure | |
| String | |
| ), | |
| ProofVerification(#[from] ProofVerificationError), |
seems like you missed to replace this
| HashMismatch { | ||
| /// The expected hash value | ||
| expected: String, | ||
| /// The actual hash value found | ||
| found: String, | ||
| }, |
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.
these should probably be B256, no?
| /// Error during RLP encoding/decoding | ||
| #[error("RLP error: {0}")] | ||
| RlpError( | ||
| /// The underlying RLP error | ||
| #[from] alloy_rlp::Error | ||
| ), |
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.
hints at flawed design if we need to have this variant converting alloy_rlp::Error to TrieError as well as the reverse conversion bellow TrieError to alloy_rlp::Error. seems like this variant should be removed.
| stack.push(RlpNode::from_raw_rlp(&bytes[..len]).map_err(|e| match e { | ||
| TrieError::RlpNodeTooLarge { .. } => alloy_rlp::Error::Custom("RLP node too large"), | ||
| _ => alloy_rlp::Error::Custom("unexpected error decoding RLP node"), | ||
| })?); |
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.
seems like this change can be reverted since the conversion From<TrieError> for alloy_rlp::Error was implemented
| Self::from_raw_rlp(bytes).map_err(|e| match e { | ||
| TrieError::RlpNodeTooLarge { size: _, max: _ } => { | ||
| alloy_rlp::Error::Custom("RLP node too large") | ||
| } | ||
| _ => alloy_rlp::Error::Custom("unexpected error decoding RLP node"), | ||
| }) |
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.
same here, can just propagate now
| pub fn from_raw_rlp(data: &[u8]) -> Result<Self, TrieError> { | ||
| Self::from_raw(data).ok_or_else(|| TrieError::RlpNodeTooLarge { | ||
| size: data.len(), | ||
| max: MAX, | ||
| }) |
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.
makes more sense if this returns alloy_rlp::Result<Self> still and just do TrieError::RlpNodeTooLarge.into()
Improve the error handling by using
thiserrorforcore::error::Errorimplementations.Fixes #90