Skip to content
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

Get rid of RlpDecodingError crutch #13

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

cburgdorf
Copy link
Owner

What was wrong

We previously introduced a crutch struct RlpDecodingError that we would map to just to then implement From<RlpDecoderError> for PyErr.

How was it fixed

A custom trait

pub trait ToDecodingError<T> {
  fn map_decoder_error(self) -> Result<T, PyErr>;
}

impl<T> ToDecodingError<T> for Result<T, rlp::DecoderError> {
  fn map_decoder_error(self) -> Result<T, PyErr> {
      self.map_err(|val | DecodingError::py_err(val.to_string()))
  }
}

We can then directly call rlp_val.payload_info().map_decoder_error() and goint straight into a DecodingError instead of going through a RlpDecodingError first.

@cburgdorf
Copy link
Owner Author

@g-r-a-n-t not trying to drag you into reviews but since I already pinged you I at least wanted to raise attention for this further change that I'm planing to land.

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.

1 participant