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

Mention JSON format in dart2js args error message #3414

Merged
merged 1 commit into from Dec 3, 2022

Conversation

natebosch
Copy link
Member

For --define arguments build_runner will attempt a JSON parse, and
treat anything with a format error as a String.
Parsing as JSON allows for structured content, similar to what can be
added in build.yaml. Silently falling back to the input as a string
avoids requiring extra quotes for the majority of simple options.

When the JSON decode fails unexpectedly, the error message can be
confusing and does not point to the problem. It's not easy to
distinguish between a build.yaml with a String value (that never would
be parsed as JSON) or command line argument, so we cannot tell for sure
if JSON formatting is the problem. The best we can do is point out that
it may have failed to parse.

Remove the name of the argument from the message, it is already present
in the ArgumentError.toString().

For `--define` arguments build_runner will attempt a JSON parse, and
treat anything with a format error as a `String`.
Parsing as JSON allows for structured content, similar to what can be
added in `build.yaml`. Silently falling back to the input as a string
avoids requiring extra quotes for the majority of simple options.

When the JSON decode fails unexpectedly, the error message can be
confusing and does not point to the problem. It's not easy to
distinguish between a `build.yaml` with a String value (that never would
be parsed as JSON) or command line argument, so we cannot tell for sure
if JSON formatting is the problem. The best we can do is point out that
it may have failed to parse.

Remove the name of the argument from the message, it is already present
in the `ArgumentError.toString()`.
@natebosch natebosch merged commit cf0671c into master Dec 3, 2022
@natebosch natebosch deleted the bwc-json-decode-message branch December 3, 2022 17:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants