Skip to content

Add human-readable messages for FloatError WasmEncodedError#240

Open
thedavidmeister wants to merge 1 commit into
mainfrom
2026-06-14-issue-77
Open

Add human-readable messages for FloatError WasmEncodedError#240
thedavidmeister wants to merge 1 commit into
mainfrom
2026-06-14-issue-77

Conversation

@thedavidmeister

Copy link
Copy Markdown
Contributor

Fixes the // todo: add detailed readable msg for errors in crates/float/src/error.rs: WasmEncodedError.readable_msg previously just duplicated the short msg (a Display/Debug dump).

What changed

  • FloatError::to_readable_msg(&self) -> String — a match over every FloatError variant producing a detailed, human-readable message (following the established rain ecosystem pattern, e.g. raindex's Error::to_readable_msg).
  • DecimalFloatErrorSelector::to_readable_msg(&self) -> &'static str — a detailed message per Solidity DecimalFloat error selector (all 9 variants: CoefficientOverflow, ExponentOverflow, ExponentUnderflow, FixedDecimalOverflow, Log10Negative, Log10Zero, LossyConversionFromFloat, NegativeFixedDecimalConversion, WithTargetExponentOverflow), derived from the @dev docs of the underlying error/*.sol definitions.
  • From<FloatError> for WasmEncodedError now sets readable_msg from to_readable_msg() (it kept msg = to_string() for the short message).

This is mechanical message text only — no change to any error condition, selector mapping, or control flow.

Tests

Added a mutation-validated #[cfg(test)] mod tests in error.rs (source-organized) asserting the exact message for representative variants, the known/unknown DecimalFloatSelector arms, and that WasmEncodedError wires readable_msg from to_readable_msg (distinct from msg).

Mutation-validated: breaking the Log10Zero selector text killed both selector-asserting tests; breaking the readable_msg wiring (back to to_string()) killed the WasmEncodedError test; restored to green.

cargo test -p rain-math-float green (82 lib unittests + 36 doctests), cargo fmt --check and cargo clippy --all-targets clean.

Scoped entirely to crates/float/src/error.rs; does not touch canonicalize (#237) or pow (#232/#239) work.

Closes #77

Fill in the detailed `readable_msg` of `WasmEncodedError` for every
`FloatError` variant via a new `FloatError::to_readable_msg`, and a
`DecimalFloatErrorSelector::to_readable_msg` for each Solidity
`DecimalFloat` error selector. Previously `readable_msg` duplicated the
short `msg`. Mechanical message text only; no change to error conditions.

Closes #77

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@thedavidmeister thedavidmeister self-assigned this Jun 14, 2026
@coderabbitai

coderabbitai Bot commented Jun 14, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

@thedavidmeister, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 56 minutes and 18 seconds. Learn how PR review limits work.

Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file).

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: bf60cd64-b40c-4667-966c-29bea22a1ce0

📥 Commits

Reviewing files that changed from the base of the PR and between 95108e2 and 4e770aa.

📒 Files selected for processing (1)
  • crates/float/src/error.rs
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch 2026-06-14-issue-77

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

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.

update and improve human readable msgs for WasmEncodedError of FloatError

1 participant