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

cli: render string pattern suggestion as a hint #3399

Merged
merged 6 commits into from
Mar 30, 2024

Conversation

yuja
Copy link
Contributor

@yuja yuja commented Mar 30, 2024

Checklist

If applicable:

  • I have updated CHANGELOG.md
  • I have updated the documentation (README.md, docs/, demos/)
  • I have updated the config schema (cli/src/config-schema.json)
  • I have added tests to cover my changes

yuja added 6 commits March 30, 2024 22:42
…or object

I'm going to add RevsetParseError constructor for InvalidFunctionArguments,
with/without a source error, and I don't want to duplicate code for all
combinations. The templater change is just for consistency.

I couldn't find a good naming convention for the builder-like API, so it's
called .with_source(mut self, _). Another option was .source_set(source).
Apparently, it's not uncommon to name consuming constructor as
with_<something>().
I also renamed "UnexpectedExpression" to just "Expression" because "unexpected"
doesn't apply to "immutable" revset parse/evaluation errors.
It was only needed to attach the source error object, which is now handled
by the outer error type.
Inlined some of the make_error() closures instead. I'll make string pattern
handler preserve the source error object.
This helps to add hint at the CLI layer.
Templater doesn't have the one yet, but I think it belongs to the same
category.

For clap::Error, we could use clap's own mechanism to render suggestions as
"tip: ...", but I feel "Hint: ..." looks better because our error/hint message
is capitalized.
@yuja yuja force-pushed the push-luzypoytmqsp branch from 54919d7 to 426b18d Compare March 30, 2024 13:44
Copy link
Member

@martinvonz martinvonz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice. Thanks for all these error handling improvements!

@yuja yuja merged commit a6615bf into jj-vcs:main Mar 30, 2024
16 checks passed
@yuja yuja deleted the push-luzypoytmqsp branch March 30, 2024 14:53
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.

2 participants