Skip to content

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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

eseidel
Copy link

@eseidel eseidel commented May 5, 2025

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!

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!
@eseidel
Copy link
Author

eseidel commented May 5, 2025

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.

Copy link

github-actions bot commented May 5, 2025

PR Health

Breaking changes ✔️
Package Change Current Version New Version Needed Version Looking good?
args None 2.7.0 2.7.0 2.7.0 ✔️
Changelog Entry ✔️
Package Changed Files

Changes to files need to be accounted for in their respective changelogs.

Coverage ✔️
File Coverage
pkgs/args/lib/src/arg_results.dart 💚 88 %

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.

Package Leaked API symbols
License Headers ✔️
// Copyright (c) 2025, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
Files
no missing headers

All source files should start with a license header.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

package:args shouldn't throw ArgumentError on missing argument
1 participant