Do not call the caller's typo a library defect - #1033
Merged
Conversation
SpecialSet.Create(string) and SpecialSet.Create(Domain) are both public, and
both answered an input they did not recognise with AngouriBugException, whose
message asks the caller to report the problem to this repository. Somebody who
writes "NN" is told their own typo is a defect here.
The string overload now throws UnrecognizedDomainException, which has existed
for exactly this since it was written and which nothing threw. The Domain
overload throws NotSufficientlySupportedException, because Domain.Any is a
documented member of the enum -- it means no restriction, which is not a set
this library has a node for -- and a value cast in from outside the enum is not
one either. Neither is the library's fault and neither now says it is.
Both stay under AngouriMathBaseException, so the catch the documentation tells
a caller to write is unaffected, and a test pins that.
Measured on a build of each side, with every accepted name and every domain
that is a set checked to still answer:
Create("NN") AngouriBugException -> UnrecognizedDomainException
Create(Domain.Any) AngouriBugException -> NotSufficientlySupportedException
Create((Domain)99) AngouriBugException -> NotSufficientlySupportedException
Create("RR") RR -> RR
Nothing inside the library reaches either arm: Domains.IsWithinDomain answers
Domain.Any before Create sees it, and the only other route into the string
overload is a SPECIALSET token, every spelling of which the switch lists.
#1027 improved this site's message and left it an AngouriBugException; this branch changes what it throws. Merging kept both, which is two default arms in one switch and does not compile. The point of this change is that neither site is a library defect, so the AngouriBugException arms go and the messages that say what the caller passed stay.
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.
Entity.Set.SpecialSet.Create(string)andEntity.Set.SpecialSet.Create(Domain)are bothpublic,and both answered an input they did not recognise with
AngouriBugException— whose message ends"please report about it to the official repository". Somebody who writes
"NN"is told their owntypo is a defect in this library and asked to file it.
UnrecognizedDomainExceptionhas existed for exactly this case since it was written, and nothingthrew it.
The second overload is the sharper one:
Domain.Anyis a documented member of the public enum.It means no restriction, which is not a set this library has a node for —
Domains.IsWithinDomainanswers it before ever reaching
Create— so the only way to hit that arm is from outside, withvalid public API, and the answer was "report this as a bug".
Measured, on a build of each side
NotSufficientlySupportedExceptionrather than a parse error for the second, because the caller'svalue is well formed and this library has no set for it — which is what that type means per
Docs/Usage/Exceptions.md.Both stay under
AngouriMathBaseException, so thecatchthe documentation tells a caller towrite is unaffected, and a test pins that. Nothing inside the library reaches either arm: the only
other route into the string overload is a
SPECIALSETtoken, every spelling of which the switchlists.
Verification
Sources/Tests/UnitTests/Core/UnknownDomainIsNotABugTest.cs, covering all tenaccepted names, all five domains that are sets, both refusal paths, and the base-exception
guarantee.
masterbaseline of7533 / 0 / 14 — exactly the 22 added, nothing else moved.
BREAKING-CHANGES.mdentry with both values, measured rather than read off the diff.Merge order
Adds an
## Unreleasedsection toBREAKING-CHANGES.md, so it costs one mechanical conflict roundagainst any other branch that adds one — #1025 does. It also appends a
file_header_templatescopeto
Sources/.editorconfig, which #1016, #1017, #1025 and #1027 also append to; all the entriessurvive that resolution.
Found while documenting the exception hierarchy for
#746 item 11 (#1027), which correctly left
it alone because changing which type a site throws is a breaking change and that PR is not.
Related: #1028 is the same wrong claim in a different place —
SumAll()on an empty sequence.