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

fix: Clean up and decouple interledge-packet::ParseError in other crates #722

Merged
merged 5 commits into from
May 19, 2021

Conversation

whalelephant
Copy link
Contributor

@whalelephant whalelephant commented May 12, 2021

cc #708

This attempts to decouple the error type ParseError in interledger-packet with other crates.
The idea is to have more explicit errors that are more efficient.

@whalelephant whalelephant marked this pull request as ready for review May 14, 2021 10:28
Copy link
Collaborator

@koivunej koivunej left a comment

Choose a reason for hiding this comment

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

Overall I think this looks very good; you updated it during my scan through, so some things might already be good to resolve.

There are some string nits; perhaps the biggest issue is with the changed messages. Are you sure those can change? I think I reverted some changes as well in the bytes 0.5 upgrade, so I'd be inclined to keep the external behaviour (the messages) as the same by default when refactoring.

Either way, I think at least the interledger-packet::Error commits need a ! to signify a breaking change (since those at minimum are exported).

EDIT: thought about it a bit, expanded the I'd be inclined to keep the external behaviour (the messages) as the same by default when refactoring.

crates/interledger-packet/src/errors.rs Outdated Show resolved Hide resolved
crates/interledger-packet/src/packet.rs Outdated Show resolved Hide resolved
crates/interledger-packet/src/packet.rs Show resolved Hide resolved
crates/interledger-packet/src/packet.rs Outdated Show resolved Hide resolved
crates/interledger-packet/src/packet.rs Outdated Show resolved Hide resolved
crates/interledger-stream/src/error.rs Outdated Show resolved Hide resolved
crates/interledger-stream/src/error.rs Outdated Show resolved Hide resolved
crates/interledger-stream/src/packet.rs Outdated Show resolved Hide resolved
crates/interledger-stream/src/packet.rs Outdated Show resolved Hide resolved
crates/interledger-ccp/src/packet.rs Show resolved Hide resolved
@whalelephant whalelephant force-pushed the packet-errors branch 4 times, most recently from 3246d40 to 54738fc Compare May 17, 2021 09:50
#[error("UTF-8 Error: {0}")]
Utf8Err(#[from] Utf8Error),
#[error("UTF-8 Conversion Error: {0}")]
FromUtf8Err(#[from] FromUtf8Error),
#[error("Chrono Error: {0}")]
ChronoErr(#[from] chrono::ParseError),
Copy link
Collaborator

Choose a reason for hiding this comment

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

Just a note for the follow-ups: I dont think there's any point in carrying this around either. If the timestamp isn't good it doesn't really matter how bad is it. I think chrono::ParseError is quite uninformative as well.

pub(crate) fn try_from_without_expiry(prepare: &Prepare) -> Result<Self, CcpPacketError> {
let destination = prepare.destination();
if destination != *CCP_CONTROL_DESTINATION {
return Err(CcpPacketError::UnexpectedDestination(destination));
}

if prepare.execution_condition() != PEER_PROTOCOL_CONDITION {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Interesting aside note: This check is duplicated along with it's log stmt... Probably not great to log and return an error but ok to clean this up later.

Copy link
Collaborator

@koivunej koivunej left a comment

Choose a reason for hiding this comment

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

I think this is looking great! Much less format!(...).

As discussed the std::io::Error will be gotten rid from interledger-packet/src/oer.rs with a more specific simpler enum in a follow-up.

@koivunej
Copy link
Collaborator

The latest test-md fail is bening installation failure, no worries there.

@koivunej
Copy link
Collaborator

Rerunning as the other one failed to start as well.

@koivunej
Copy link
Collaborator

Github actions is having issues, we'll need to restart later.

Introduce TrailingBytesError, DataTypeError, PacketTypeError

Signed-off-by: bwty <whalelephant@users.noreply.github.com>
Signed-off-by: bwty <whalelephant@users.noreply.github.com>

Signed-off-by: bwty <whalelephant@users.noreply.github.com>
Signed-off-by: bwty <whalelephant@users.noreply.github.com>
Signed-off-by: bwty <whalelephant@users.noreply.github.com>
Signed-off-by: bwty <whalelephant@users.noreply.github.com>
@koivunej koivunej merged commit 0fcaf5d into interledger:master May 19, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants