-
Notifications
You must be signed in to change notification settings - Fork 23
package:args shouldn't throw ArgumentError on missing argument #872
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
Comments
I could argue that Error subclasses are for things that the programmer should have prevented through proper coding but failed to do so. But this error seems to be correct code and a problem with the data. I could easily argue that this should be an API Exception rather than a programmer Error. |
You're wrong 😉 In line 69 it checks if the name the programmer passes in is one that the same programmer has defined in the parser options for the parser. If there is no defined option with that name, then it's not a name of an option at all. In line 74, an core/pkgs/args/lib/src/arg_results.dart Lines 73 to 74 in 61e6771
The option was defined, as required even, but the parsed result contains no data for it.
Issue title checks out, example off by 5 lines. I think that's close enough! |
Confirmed: Line 74 is hit: core/pkgs/args/lib/src/arg_results.dart Line 74 in 61e6771
|
I'm also not sure why we're not hitting: core/pkgs/args/lib/src/parser.dart Line 108 in 61e6771
So presumably there are two bugs here. |
ArgumentError is an Error and thus supposed to be used for programmer errors.
ArgResults.operator[] throws ArgumentError on what should be a runtime error:
core/pkgs/args/lib/src/arg_results.dart
Line 69 in 61e6771
Am I wrong?
The text was updated successfully, but these errors were encountered: