-
Notifications
You must be signed in to change notification settings - Fork 23
fix: ArgResults.operator[] should throw Exception not Error #888
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
base: main
Are you sure you want to change the base?
Conversation
ArgResults.operator[] and ArgResults.option() would throw ArgumentError instead of Exception when the user would fail to pass all expected arguments. Errors are only supposed to be thrown on programmer error so changed to throw ArgParserException instead. This is a breaking change!
I'm honestly not sure if this is worth landing, as there is a non-trivial risk of breaking lots of apps in the wild. |
PR HealthBreaking changes ✔️
Changelog Entry ✔️
Changes to files need to be accounted for in their respective changelogs. Coverage ✔️
This check for test coverage is informational (issues shown here will not fail the PR). API leaks ✔️The following packages contain symbols visible in the public API, but not exported by the library. Export these symbols or remove them from your publicly visible API.
License Headers ✔️
All source files should start with a license header. |
Yeah, I like the spirit of this change, but actually rolling it out seems like a nightmare. I definitely don't have time to actively maintain args. If someone else on the Dart team wants to drive this through shipping, I support it, but I can't shepherd it myself. |
FYI, you're getting these reviews due to a recent change to the https://github.com/dart-lang/core/blob/main/.github/CODEOWNERS file; if you'd prefer not to get them, feel free to update that file (likely to change the reviewers to the ecosystem team).
I suspect that the mandatory feature probably shouldn't have landed; this use of errors instead of exceptions was introduced then. We have a Separately, I wonder if the least overall disruption for users is changing the exception type, or, removing the |
Oh, well how about that. Sent a PR: #891
Yeah, I didn't love it when I first saw that go by. Definitely a well-intentioned feature, but it doesn't fit very well with existing API for how args works.
The least painful option is to probably leave things as they are with the current exception type. If we do want to support mandatory options, we should probably re-work the API so that you can't get your hands on an |
ArgResults.operator[] and ArgResults.option() would throw ArgumentError instead of Exception when the user would fail to pass all expected arguments.
Errors are only supposed to be thrown on programmer error so changed to throw ArgParserException instead.
Fixes #872
This is a breaking change!