Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use ArgumentOutOfRangeException instead of IndexOutOfRangeException outside of indexers #1023

Open
paulirwin opened this issue Nov 15, 2024 · 0 comments
Labels
is:task A chore to be done pri:low

Comments

@paulirwin
Copy link
Contributor

paulirwin commented Nov 15, 2024

I discovered that inside of several of the methods of BitVector, we are throwing IndexOutOfRangeException. IndexOutOfRangeException is a special exception type in .NET that should only be thrown from the getter of an indexer. In virtually all other cases, these should be converted to ArgumentOutOfRangeException. Looks like there are a handful of other types that are throwing it, as well. We should ... convert these to ArgumentOutOfRangeException and double-check that there will be no adverse effects from making the change. These were originally intentionally normalized to IndexOutOfRangeException to make the error handling simpler, but since then we have fixed the error handling to catch either IndexOutOfRangeException or ArgumentOutOfRangeException and treat them the same using the IsIndexOutOfBoundsException() extension method (although, it may not be used everywhere it is needed to make the change).

Originally posted by @NightOwl888 in #1018 (comment)

@paulirwin paulirwin mentioned this issue Nov 15, 2024
4 tasks
@paulirwin paulirwin added this to the 4.8.0-beta00018 milestone Nov 18, 2024
@paulirwin paulirwin added pri:low is:task A chore to be done labels Nov 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
is:task A chore to be done pri:low
Projects
None yet
Development

No branches or pull requests

1 participant