fix(#166): preserve Utf8Error detail in hex_to_str#316
Open
LeJamon wants to merge 1 commit into
Open
Conversation
XRPLUtilsException::Utf8Error was a unit variant and its From impl discarded the underlying core::str::Utf8Error, hiding the position and valid-up-to information. Carry the Utf8Error so callers can diagnose which byte was invalid.
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Closes #166.
XRPLUtilsException::Utf8Errorwas a unit variant, and itsFrom<core::str::Utf8Error>impl ignored its argument (fn from(_) -> Self). Every UTF-8 failure inhex_to_strtherefore collapsed to a detail-free "Invalid UTF-8", discarding theUtf8Errorposition (valid_up_to()/error_len()).The variant now carries the underlying
core::str::Utf8Error(via#[from]), so callers can diagnose exactly which byte was invalid.Testing
cargo test --lib— addedtest_hex_to_str_invalid_utf8_preserves_detailcargo fmt --check,cargo test --doc--no-default-features --features embassy-rt,core,utils,wallet,models,helpers,websocket,json-rpc) builds and tests green