Repository navigation
Render a domain error's argument in E notation, so its message stays short [patch] - #192
Merged
Merged
Conversation
…short [patch] Every domain check passed the PreciseNumber argument itself as ActualValue, and ArgumentOutOfRangeException.Message renders that with ToString(), which writes fixed point. Reading the message of Sqrt(-1e-2147483648) threw OverflowException, Log(-1e2000000000) and Asin(1e2000000000) ran out of memory, and Log(-1e-200000000) spent seconds building a 200-million-character string, so a handler that logs e.Message crashed or stalled instead of reporting the domain error. All ten checks now build their exception through DomainError, which carries the argument in E notation with up to thirty fractional digits. Fixes #190 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017vfJW2U6qwK2oTLt2cfE7k
|
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.



Fixes #190
What was wrong
Every domain check passed the
PreciseNumberargument itself asActualValue.ArgumentOutOfRangeException.Messagerenders that value withToString(), which writes fixed point:Sqrt(-1e-2147483648)threwOverflowException.Log(-1e2000000000)andAsin(1e2000000000)ran out of memory.Log(-1e-200000000)took seconds to build a 200-million-character string.As a result, a
catch (Exception e) { log(e.Message); }handler crashed or stalled instead of reporting the domain error.Change
A single
DomainError(paramName, value, message)helper, inPreciseNumber.Exponentials.cs, builds the exception for all ten checks:PowThe argument is carried as an
E-format string with up to 30 fractional digits. A typical argument therefore keeps every digit (-12.5→-1.25E+001), and an extreme one stays a few dozen characters long.ActualValueis now that string rather than thePreciseNumber. Nothing in the repo read it as a number.Tests
PreciseNumberDomainErrorTeststriggers every domain check with arguments of±1e±2000000000and±1e-2147483648, as each check's domain allows, plus-1e-200000000for Log. Each test reads.Messageand asserts it is under 1,000 characters. Two more tests pin the rendering itself: theParamName,ActualValueand message ofSqrt(-12.5), and 30 fractional digits of-π.With the library change stashed, all 31 new tests fail. Some fail by throwing from
.Message. The Log cases take 8 to 11 s each to build their message before failing on its length. With the change, the full suite passes: 617/617. I also added the new test file to the test-structure paragraph inCLAUDE.md.Generated by Claude Code