Skip to content

fix(#166): preserve Utf8Error detail in hex_to_str#316

Open
LeJamon wants to merge 1 commit into
XRPLF:mainfrom
LeJamon:fix/issue-166
Open

fix(#166): preserve Utf8Error detail in hex_to_str#316
LeJamon wants to merge 1 commit into
XRPLF:mainfrom
LeJamon:fix/issue-166

Conversation

@LeJamon

@LeJamon LeJamon commented May 30, 2026

Copy link
Copy Markdown

Closes #166.

XRPLUtilsException::Utf8Error was a unit variant, and its From<core::str::Utf8Error> impl ignored its argument (fn from(_) -> Self). Every UTF-8 failure in hex_to_str therefore collapsed to a detail-free "Invalid UTF-8", discarding the Utf8Error position (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 — added test_hex_to_str_invalid_utf8_preserves_detail
  • cargo fmt --check, cargo test --doc
  • no_std feature set (--no-default-features --features embassy-rt,core,utils,wallet,models,helpers,websocket,json-rpc) builds and tests green

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.
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.

hex_to_str discards the UTF-8 error detail

1 participant