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

Verbose alternation-in-optional error message #260

Merged

Conversation

kieran-ryan
Copy link
Sponsor Member

🤔 What's changed?

Updated error message for an alternation inside an optional from...

An alternation can not be used inside an optional
You can use '\\/' to escape the '/'

...to...

An alternation can not be used inside an optional
If you did not mean to use an alternation you can use '\\/' to escape the '/'. Otherwise rephrase your expression or consider using a regular expression instead.

⚡️ What's your motivation?

  1. Improve error message consistency
    • Was You can use '\\/' to escape the '/'; while AlternativeMayNotBeEmpty message for similar is If you did not mean to use an alternative you can use '\\/' to escape the '/'
  2. Improve clarity on how to fix if user intention was indeed to use an alternation and an optional. With d(a/o), fixes would be:
    • d(a\/o) - if wanted d and da/o
    • d/da/do, d(a)/do or d(a)/d(o) - if wanted d, da and do
    • or to perhaps use a regular expression

Allows to close cucumber/vscode#142 by improving clarity that message is expected behaviour - so is not re-raised.

🏷️ What kind of change is this?

  • 🐛 Bug fix (non-breaking change which fixes a defect)

♻️ Anything particular you want feedback on?

Whether Otherwise rephrase your expression or consider using a regular expression instead. portion is clear or can be improved.

📋 Checklist:

  • I agree to respect and uphold the Cucumber Community Code of Conduct
  • I've changed the behaviour of the code
    • I have added/updated tests to cover my changes.
  • Users should know about my change
    • I have added an entry to the "Unreleased" section of the CHANGELOG, linking to this pull request.

@kieran-ryan kieran-ryan self-assigned this Dec 23, 2023
Copy link
Contributor

@mpkorstanje mpkorstanje left a comment

Choose a reason for hiding this comment

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

LGTM. But I don't see the changelog entry. Feel free to merge after adding.

@mpkorstanje mpkorstanje changed the title Verbose alternation in optional error message Verbose alternation-in-optional error message Dec 28, 2023
@kieran-ryan kieran-ryan merged commit d623c9a into cucumber:main Dec 30, 2023
25 checks passed
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.

Bug report: An alternation can not be used inside an optional.
2 participants