Add human-readable messages for FloatError WasmEncodedError#240
Add human-readable messages for FloatError WasmEncodedError#240thedavidmeister wants to merge 1 commit into
Conversation
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>
|
Warning Review limit reached
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 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 configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (1)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
Fixes the
// todo: add detailed readable msg for errorsincrates/float/src/error.rs:WasmEncodedError.readable_msgpreviously just duplicated the shortmsg(aDisplay/Debugdump).What changed
FloatError::to_readable_msg(&self) -> String— amatchover everyFloatErrorvariant producing a detailed, human-readable message (following the established rain ecosystem pattern, e.g. raindex'sError::to_readable_msg).DecimalFloatErrorSelector::to_readable_msg(&self) -> &'static str— a detailed message per SolidityDecimalFloaterror selector (all 9 variants:CoefficientOverflow,ExponentOverflow,ExponentUnderflow,FixedDecimalOverflow,Log10Negative,Log10Zero,LossyConversionFromFloat,NegativeFixedDecimalConversion,WithTargetExponentOverflow), derived from the@devdocs of the underlyingerror/*.soldefinitions.From<FloatError> for WasmEncodedErrornow setsreadable_msgfromto_readable_msg()(it keptmsg = 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 testsinerror.rs(source-organized) asserting the exact message for representative variants, the known/unknownDecimalFloatSelectorarms, and thatWasmEncodedErrorwiresreadable_msgfromto_readable_msg(distinct frommsg).Mutation-validated: breaking the
Log10Zeroselector text killed both selector-asserting tests; breaking thereadable_msgwiring (back toto_string()) killed theWasmEncodedErrortest; restored to green.cargo test -p rain-math-floatgreen (82 lib unittests + 36 doctests),cargo fmt --checkandcargo clippy --all-targetsclean.Scoped entirely to
crates/float/src/error.rs; does not touch canonicalize (#237) or pow (#232/#239) work.Closes #77